Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java Concurrent°üѧϰ֮BlockingQueue

BlockingQueueÊÇÒ»¸ö½Ó¿Ú£¬Ëü´ÓQueue¼Ì³Ð¶øÀ´£¬
°üº¬ÁËQueueµÄËùÓй¦ÄÜ£¬²¢ÔÚQueueµÄ»ù´¡ÉÏÌṩÁË2¸öÐµĹ¦ÄÜ£º
    1. ¼ìË÷ÔªËØʱµÈ´ý¶ÓÁбäΪ·Ç¿Õ
    2. ´æ´¢ÔªËØʱµÈ´ý¿Õ¼ä±äµÃ¿ÉÓá£
 
ÏÂÃ泭¼һЩJDKÎĵµÖйØÓÚBlockingQueueµÄ½éÉÜ£º
BlockingQueue ¿ÉÒÔÊÇÏÞ¶¨ÈÝÁ¿µÄ¡£ËüÔÚÈÎÒâ¸ø¶¨Ê±¼ä¶¼¿ÉÒÔÓÐÒ»¸ö remainingCapacity£¬³¬³ö´ËÈÝÁ¿£¬±ãÎÞ·¨ÎÞ×èÈûµØ put ¶îÍâµÄÔªËØ¡£Ã»ÓÐÈκÎÄÚ²¿ÈÝÁ¿Ô¼ÊøµÄ BlockingQueue ×ÜÊDZ¨¸æ Integer.MAX_VALUE µÄÊ£ÓàÈÝÁ¿¡£
BlockingQueue ʵÏÖÖ÷ÒªÓÃÓÚÉú²úÕß-ʹÓÃÕ߶ÓÁУ¬µ«ËüÁíÍ⻹֧³Ö Collection ½Ó¿Ú¡£Òò´Ë£¬¾ÙÀýÀ´Ëµ£¬Ê¹Óà remove(x) ´Ó¶ÓÁÐÖÐÒƳýÈÎÒâÒ»¸öÔªËØÊÇÓпÉÄܵġ£È»¶ø£¬ÕâÖÖ²Ù×÷ͨ³£²» »áÓÐЧִÐУ¬Ö»ÄÜÓмƻ®µØż¶ûʹÓ㬱ÈÈçÔÚÈ¡ÏûÅŶÓÐÅϢʱ¡£
BlockingQueue ʵÏÖÊÇḬ̈߳²È«µÄ¡£ËùÓÐÅŶӷ½·¨¶¼¿ÉÒÔʹÓÃÄÚ²¿Ëø¶¨»òÆäËûÐÎʽµÄ²¢·¢¿ØÖÆÀ´×Ô¶¯´ïµ½ËüÃǵÄÄ¿µÄ¡£È»¶ø£¬´óÁ¿µÄ Collection ²Ù×÷£¨addAll¡¢containsAll¡¢retainAll ºÍ removeAll£©Ã»ÓÐ ±ØÒª×Ô¶¯Ö´ÐУ¬³ý·ÇÔÚʵÏÖÖÐÌرð˵Ã÷¡£Òò´Ë£¬¾ÙÀýÀ´Ëµ£¬ÔÚÖ»Ìí¼ÓÁË c ÖеÄһЩԪËغó£¬addAll(c) ÓпÉÄÜʧ°Ü£¨Å׳öÒ»¸öÒì³££©¡£
BlockingQueue ʵÖÊÉϲ» Ö§³ÖʹÓÃÈκÎÒ»ÖÖ“close”»ò“shutdown”²Ù×÷À´Ö¸Ê¾²»ÔÙÌí¼ÓÈκÎÏî¡£ÕâÖÖ¹¦ÄܵÄÐèÇóºÍʹÓÃÓÐÒÀÀµÓÚʵÏÖµÄÇãÏò¡£ÀýÈ磬һÖÖ³£ÓõIJßÂÔÊÇ£º¶ÔÓÚÉú²úÕߣ¬²åÈëÌØÊâµÄ end-of-stream »ò poison ¶ÔÏ󣬲¢¸ù¾ÝʹÓÃÕß»ñÈ¡ÕâЩ¶ÔÏóµÄʱ¼äÀ´¶ÔËüÃǽøÐнâÊÍ¡£
ÔÚJDK1.5ÖÐÌṩÁËBlockingQueueµÄÈçÏÂʵÏÖÀࣺ
1. ArrayBlockingQueue
2. LinkedBlockingQueue
3. PriorityBlockingQueue
4. SynchronousQueue
5. DelayQueue
ÏÂÃæÎÒÃÇÀ´Ò»Ò»½éÉÜÕâЩBolackingQueueʵÏÖµÄÌص㣺
1. ArrayBlockingQueue
¹ÊÃû˼Ò⣬ArrayBlockingQueueÊÇÒ»¸öÓÉÊý×éÖ§³ÖµÄÓнç×èÈû¶ÓÁС£´Ë¶ÓÁа´ FIFO£¨ÏȽøÏȳö£©Ô­Ôò¶ÔÔªËؽøÐÐÅÅÐò¡£¶ÓÁеÄÍ·²¿ ÊÇÔÚ¶ÓÁÐÖдæÔÚʱ¼ä×µÄÔªËØ¡£¶ÓÁеÄβ²¿ ÊÇÔÚ¶ÓÁÐÖдæÔÚʱ¼ä×î¶ÌµÄÔªËØ¡£ÐÂÔªËزåÈëµ½¶ÓÁеÄβ²¿£¬¶ÓÁмìË÷²Ù×÷ÔòÊÇ´Ó¶ÓÁÐÍ·²¿¿ªÊ¼»ñµÃÔªËØ¡£
ÕâÊÇÒ»¸öµäÐ͵ēÓн绺´æÇø”£¬¹Ì¶¨´óСµÄÊý×éÔÚÆäÖб£³ÖÉú²úÕß²åÈëµÄÔªËغÍʹÓÃÕßÌáÈ¡µÄÔªËØ¡£Ò»µ©´´½¨ÁËÕâÑùµÄ»º´æÇø£¬¾Í²»ÄÜÔÙÔö¼ÓÆäÈÝÁ¿¡£ÊÔͼÏòÒÑÂú¶ÓÁÐÖзÅÈëÔªËػᵼÖ·ÅÈë²Ù×÷ÊÜ×èÈû£»ÊÔͼ´Ó¿Õ¶ÓÁÐÖмìË÷ÔªËؽ«µ¼ÖÂÀàËÆ×èÈû¡£
´ËÀàÖ§³Ö¶ÔµÈ´ýµ


Ïà¹ØÎĵµ£º

wikiϵͳ£¨JAVA£© ¹Û²ì


×î½üÏë¶ÔÓÚwikiϵͳµÄÔ´´úÂëÑо¿ÏÂ
 
jspwikiÊÇÒ»¸ö²»´íµÄwikiÒýÇ棬´¿jsp/servletдµÄ¡£JSPWiki²»Ê¹ÓÃÏֳɵÄÊý¾Ý¿â¹ÜÀíÈí¼þ£¬ËùÓеÄÎļþÒÔÎı¾ÎļþµÄÐÎʽ´æ·Å¡£ËüÀûÓÃÀàËÆCVSµÄ»úÖƱ£Ö¤ÁËÎļþ°æ±¾µÄÍêÕûÐÔ¡£Ö§³ÖÖÐÎÄ£¬Ö§³Ö°æ±¾±È½Ï¡¢È¨ÏÞ¹ÜÀíµÈ¹¦ÄÜ£¡
ÏîÄ¿Ö÷Ò³£º http://www.jspwiki.org/
ÎĵµµØÖ·£º  ......

Ö÷Ì⣺Java³ÌÐòÔ±µÄ֪ʶ¼Ü¹¹Ç³Îö

×÷ΪJava³ÌÐòÔ±À´Ëµ£¬×îÍ´¿àµÄÊÂÇéĪ¹ýÓÚ¿ÉÒÔÑ¡ÔñµÄ·¶Î§Ì«¹ã£¬¿ÉÒÔ¶ÁµÄÊéÌ«¶à£¬ÍùÍùÈÝÒ×ÎÞËùÊÊ´Ó¡£ÎÒÏë¾ÍÎÒ×Ô¼º¶Á¹ýµÄ¼¼ÊõÊé¼®ÖÐÌôÑ¡³öÀ´Ò»Ð©£¬
°´ÕÕѧϰµÄÏȺó˳Ðò£¬ÍƼö¸ø´ó¼Ò£¬ÌرðÊÇÄÇЩÏë²»¶ÏÌá¸ß×Ô¼º¼¼ÊõˮƽµÄJava³ÌÐòÔ±ÃÇ¡£
Ò»¡¢Java±à³ÌÈëÃÅÀà
¶ÔÓÚûÓÐJava±à³Ì¾­ÑéµÄJava³ÌÐòÔ±ÒªÈëÃÅ£¬Ëæ±ã¶ÁʲôÈëÃÅÊé¼®¶¼Ò» ......

ÊÕµ½±àÒëjavaÎļþµÄ×¢ÒâÊÂÏî

ÏÂÃæÒÔ±àÒë /src/com/dream/io/ScannerTest.javaΪʾÀý£º
1¡¢ÓÃjavac±àÒë.javaÎļþʱ£¬½øÈësrcĿ¼ºó£¬ÊäÈë javac com/dream/io/ScannerTest.java£¬ »Ø³µ£¬¼´¿É±àÒëScannerTest.javaÎļþΪ.classÎļþ£»Ò²¿É£¬½øÈë /src/com/dream/io/ Ŀ¼ºó£¬ ÊäÈë javac ScannerTest.java£¬ »Ø³µ£¬Ò²¿É±àÒë ScannerTest.javaÎļþΪ .clas ......

ÔÚEclipseÖн«Java Projectת»»³ÉDynamic Web Project


±à¼­¹¤³ÌµÄ.projectÎļþ£º
Ìí¼Ó
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
µ½
<natures>

& ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ