JavaÏß³ÌÖ®Worker Thread Pattern
Worker Thread PatternµÄ²ÎÓëÕߣº
1. Client£¨Î¯ÍÐÈË£©²ÎÓëÕß
Client²ÎÓëÕ߻ὨÁ¢Request²ÎÓëÕߣ¬²¢´«¸øChannel²ÎÓëÕß¡£
2. Channel£¨Í¨Â·£©²ÎÓëÕß
Channel²ÎÓëÕß»á´ÓClient²ÎÓëÕß»ñÈ¡Request²ÎÓëÕߣ¬´«µÝ¸øWorker²ÎÓëÕß¡£
3. Worker£¨¹¤ÈË£©²ÎÓëÕß
Worker²ÎÓëÕß»á´ÓChannel²ÎÓëÕß»ñÈ¡Request²ÎÓëÕߣ¬²¢Ö´ÐÐÕâ·Ý¹¤×÷¡£µ±¹¤×÷½áÊøÖ®ºó£¬»áÈ¥ÄÃÏÂÒ»¸öRequest²ÎÓëÕß¡£
4. Request£¨ÇëÇ󣩲ÎÓëÕß
Reqeust²ÎÓëÕßÓÃÀ´±íʾ¹¤×÷¡£Request²ÎÓëÕß»á´æ·ÅÖ´ÐÐÕâ·Ý¹¤×÷ËùÐèÒªµÄÊý¾Ý¡£
---------------------------------------------
¿ØÖƳÐÔØÁ¿£º
Worker²ÎÓëÕßµÄÊýÁ¿ÊÇ¿ÉÒÔ×ÔÓÉÉèÖõġ£Ìá¸ßWorker²ÎÓëÕßµÄÊýÁ¿£¬¿ÉÒÔÌá¸ß²¢·¢´¦ÀíµÄ¹¤×÷Á¿¡£µ«ÊÇÈç¹û×¼±¸µÄWorker²ÎÓëÕßÊýÁ¿±Èͬʱ¼äµÄ¹¤×÷Á¿À´µÄ¶à£¬ÓÐЩWorker²ÎÓëÕßÒ²Åɲ»ÉÏÓ󡣬û»î¸É£¬»¹»áÕ¼ÓÃÄÚ´æ¡£ËùÒÔÓбØÒªÅäºÏʵ¼ÊÈí¼þʹÓõÄÐèÒªÀ´µ÷ÕûWorker²ÎÓëÕßµÄÊýÁ¿¡£
---------------------------------------------
InvocationÓëexecutionµÄ·ÖÀ룺
Client²ÎÓëÕ߻ᷢ³ö¹¤×÷ÇëÇ󣬹¤×÷µÄÄÚÈÝÒÔRequestµÄÐÎʽ°ü×°ÆðÀ´£¬´«µÝ¸öChannel²ÎÓëÕß¡£Õâ¸ö¹ý³Ì£¬¶ÔÓ¦ÓÚÆÕͨµÄ·½·¨µ÷ÓÃÀ´Ëµ£¬¾ÍÏ൱ÓÚ“ÆÀ¹À×Ô±äÁ¿£¬Æô¶¯·½·¨”µÄ²Ù×÷¡£
ÁíÒ»·½Ã棬Worker²ÎÓëÕß»áʹÓôÓChannel²ÎÓëÕßÄÃÀ´µÄRequest²ÎÓëÕߣ¬½øÐÐʵ¼ÊµÄ²Ù×÷¡£Õâ¸ö¹ý³Ì£¬¶ÔÓ¦ÓÚÆÕͨµÄ·½·¨µ÷ÓÃÀ´Ëµ£¬¿ÉÒÔ¶ÔÓ¦µ½“Ö´Ðз½·¨”µÄ²¿·Ö¡£
ÆÕͨµÄ·½·¨µ÷ÓõIJÙ×÷£¬“Æô¶¯·½·¨”ºÍ“Ö´Ðз½·¨”ÊÇÁ¬Ðø½øÐеġ£µ±Ò»¸ö·½·¨Ò»¾µ÷Ó㬾ͻáÂíÉϼÌÐøÖ´ÐУ¬Æô¶¯ºÍÖ´ÐÐÊÇÃܲ»¿É·ÖµÄ¡£
ÔÚWorker Thread PatternÖУ¬ÊµÏÖÁË“Æô¶¯·½·¨”ºÍ“Ö´Ðз½·¨”µÄ·ÖÀë¡£ÕâÑùµÄºÃ´¦ÓУº
1. Ìá¸ßÏìÓ¦ÐÔ¡£
invocation¿ÉÒÔ¼ÌÐø×Ô¼ºÇ°½ø£¬²»Óõȴýexecution£¬ÕâÑùÄÜÌá¸ß³ÌÐòµÄÏìÓ¦ÐÔ¡£
2. ¿ØÖÆʵÐÐ˳Ðò¡£
invocationºÍexecution·ÖÀ룬executeµÄ˳Ðò¾Í¿ÉÒÔÓëinvokeµÄ´ÎÐòÎ޹أ¬Ò²¾ÍÊÇ˵£¬ÎÒÃÇ¿ÉÒÔ¶ÔRequest²ÎÓëÕßÉèÁ¢ÓÅÏȼ¶£¬¿ØÖÆChannel²ÎÓëÕß´«µÝRequest¸øWorker²ÎÓëÕßµÄ˳Ðò¡£
3. ¿ÉÒÔÈ¡ÏûºÍÖظ´Ö´ÐС£
Èç¹ûÄܽ«invocationºÍexecution·ÖÀ룬ÄÇô¾ÍÄÜ×öµ½ÔÚexecute֮ǰ£¬°ÑÒѾinvokeµÄÇëÇóµÄexecutionÈ¡Ïûµô¡£
ͬÑù£¬Ö»Òª°ÑRequest²ÎÓëÕß±£´æÏÂÀ´£¬¾Í¿ÉÒÔÖظ´Ö´ÐС£
4. ·ÖÉ¢´¦ÀíµÄµÚÒ»²½
ÒòΪinvocationºÍexecution·ÖÀëÁË£¬ËùÒ
Ïà¹ØÎĵµ£º
±¾ÎIJÉÓÃJavaÓïÑÔд³É£¬ÒÔgoogleºÍ°Ù¶ÈËÑË÷ÒýÇæΪ¶ÔÏó¡£
ÎÒÃÇÒªÀûÓÃgoogle¡¢°Ù¶ÈËÑË÷ÒýÇæµÄËÑË÷¹æÔòÖеÄÁ½Ìõ£¬¹Ø¼ü×ÖËÑË÷ºÍinurlËÑË÷¡£Ê²Ã´ÊÇinurlËÑË÷£¬¾ÍÊÇÄãËùÒªËÑË÷µÄÍøÖ·Öб¾Éí´øÓеĹؼü×Ö£¬±ÈÈçhttp://www.xxx.com/post.asp ,Õâ¸öÍøÖ·¾Íº¬ÓÐpost.aspÕâÑùµÄ¹Ø¼ü×Ö£¬ÔÚËÑË÷ÒýÇæÖÐÌîд¹æÔòÊÇ inurl:post.asp,Õ ......
À´×Ô£ºhttp://www.anymobile.org
1¡¢ÕªÒª..........................................................................1
2¡¢¸ÄÉÆ·þÎñÆ÷µÄÐÔÄÜ...........................................................1
3¡¢·ÖÎöÆ÷ÔÀí...................................................................2
4¡¢JProfiler ¼ò½é... ......
JAVA¿ª·¢Õß×ȥµÄ20¸öÓ¢ÎÄÍøÕ¾
1.[http://www.javaalmanac.com] – Java¿ª·¢ÕßÄê¼øÒ»ÊéµÄÔÚÏß°æ±¾. ÒªÏë¿ìËٲ鵽ijÖÖJava¼¼ÇɵÄÓ÷¨¼°Ê¾Àý´úÂë, ÕâÊÇÒ»¸ö²»´íµÄÈ¥´¦.
2.[http://www.onjava.com] – O’ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ.
3.[http://java.sun.com] – ¹Ù·½µÄJava¿ª·¢ÕßÍøÕ¾ &ndash ......
Ó¦¸Ã¾ÍÊÇ°Ñjava ÀïÃæµÄ×é¼þ¸ãÃ÷°×
Servlet
ServletÊÇÒ»ÖÖ»ùÓÚwebµÄJava×é¼þ£¬ËüÓÉÈÝÆ÷¹ÜÀí£¬²¢¶¯Ì¬Éú³ÉÆäÄÚÈÝ
ÔòûÓÐͼÐνçÃ棬ÔËÐÐÔÚ·þÎñÆ÷¶Ë
ËüÃǶ¼ÓÐÒ»¸öÉú´æÖÜÆÚ£¬°üº¬init()ºÍdestroy()·½·¨
²»ÊǶÀÁ¢µÄÓ¦ÓóÌÐò£¬Ã»ÓÐmain()·½·¨
Ó봫ͳµÄCGIºÍÐí¶àÆäËûÀàËÆCGIµÄ¼¼ÊõÏà±È£¬Java Servlet¾ßÓиü¸ßµÄЧÂÊ£¬¸ ......