JavaỊ̈߳ºÐÂÌØÕ÷ ×èÈûÕ»
JavaỊ̈߳ºÐÂÌØÕ÷-×èÈûÕ»
¶ÔÓÚ×èÈûÕ»£¬Óë×èÈû¶ÓÁÐÏàËÆ¡£²»Í¬µãÔÚÓÚÕ»ÊÇ“ºóÈëÏȳö”µÄ½á¹¹£¬Ã¿´Î²Ù×÷µÄÊÇÕ»¶¥£¬¶ø¶ÓÁÐÊÇ“ÏȽøÏȳö”µÄ½á¹¹£¬Ã¿´Î²Ù×÷µÄÊǶÓÁÐÍ·¡£
ÕâÀïÒªÌرð˵Ã÷Ò»µãµÄÊÇ£¬×èÈûÕ»ÊÇJava6µÄÐÂÌØÕ÷¡£¡¢
JavaΪ×èÈûÕ»¶¨ÒåÁ˽ӿڣºjava.util.concurrent.BlockingDeque£¬ÆäʵÏÖÀàÒ²±È½Ï¶à£¬¾ßÌå¿ÉÒԲ鿴JavaAPIÎĵµ¡£
ÏÂÃæ¿´Ò»¸ö¼òµ¥Àý×Ó£º
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
/**
* JavaỊ̈߳ºÐÂÌØÕ÷-×èÈûÕ»
*
* @author leizhimin 2009-11-5 15:34:29
*/
public class Test {
public static void main(String[] args) throws InterruptedException {
BlockingDeque bDeque = new LinkedBlockingDeque(20);
for (int i = 0; i < 30; i++) {
//½«Ö¸¶¨ÔªËØÌí¼Óµ½´Ë×èÈûÕ»ÖУ¬Èç¹ûûÓпÉÓÿռ䣬½«Ò»Ö±µÈ´ý£¨Èç¹ûÓбØÒª£©¡£
bDeque.putFirst(i);
System.out.println("Ïò×èÈûÕ»ÖÐÌí¼ÓÁËÔªËØ:" + i);
}
System.out.println("³ÌÐòµ½´ËÔËÐнáÊø£¬¼´½«Í˳ö----");
}
}
Êä³ö½á¹û£º
Ïò×èÈûÕ»ÖÐÌí¼ÓÁËÔªËØ:0
Ïò×èÈûÕ»ÖÐÌí¼ÓÁËÔªËØ:1
Ïò×èÈûÕ»ÖÐÌí¼ÓÁËÔªËØ:2
Ïò×èÈûÕ»ÖÐÌí¼ÓÁËÔªËØ
Ïà¹ØÎĵµ£º
JavaỊ̈߳ºÏß³ÌջģÐÍÓëÏ̵߳ıäÁ¿
SCJP5ѧϰ±Ê¼Ç
ÒªÀí½âÏ̵߳÷¶ÈµÄÔÀí£¬ÒÔ¼°Ïß³ÌÖ´Ðйý³Ì£¬±ØÐëÀí½âÏß³ÌջģÐÍ¡£
Ïß³ÌÕ»ÊÇָijʱ¿ÌʱÄÚ´æÖÐÏ̵߳÷¶ÈµÄÕ»ÐÅÏ¢£¬µ±Ç°µ÷Óõķ½·¨×ÜÊÇλÓÚÕ»¶¥¡£Ïß³ÌÕ»µÄÄÚÈÝÊÇËæ×ųÌÐòµÄÔËÐж¯Ì¬±ä»¯µÄ£¬Òò´ËÑо¿Ïß³ÌÕ»±ØÐëÑ¡ÔñÒ»¸öÔËÐеÄʱ¿Ì£¨Êµ¼ÊÉÏÖ¸´úÂëÔËÐе½Ê²Ã´µØ· ......
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÐÝÃß
JavaÏ̵߳÷¶ÈÊÇJava¶àÏ̵߳ĺËÐÄ£¬Ö»ÓÐÁ¼ºÃµÄµ÷¶È£¬²ÅÄܳä·Ö·¢»ÓϵͳµÄÐÔÄÜ£¬Ìá¸ß³ÌÐòµÄÖ´ÐÐЧÂÊ¡£
ÕâÀïÒªÃ÷È·µÄÒ»µã£¬²»¹Ü³ÌÐòÔ±Ôõô±àдµ÷¶È£¬Ö»ÄÜ×î´óÏ޶ȵÄÓ°ÏìÏß³ÌÖ´ÐеĴÎÐò£¬¶ø²»ÄÜ×öµ½¾«×¼¿ØÖÆ¡£
Ïß³ÌÐÝÃßµÄÄ¿µÄÊÇʹÏß³ÌÈóöCPUµÄ×î¼òµ¥µÄ×ö·¨Ö®Ò»£¬Ïß³ÌÐÝÃß ......
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÊØ»¤Ïß³Ì
ÊØ»¤Ïß³ÌÓëÆÕͨÏß³Ìд·¨ÉÏ»ù±¾Ã´É¶Çø±ð£¬µ÷ÓÃÏ̶߳ÔÏóµÄ·½·¨setDaemon(true)£¬Ôò¿ÉÒÔ½«ÆäÉèÖÃΪÊØ»¤Ï̡߳£
ÊØ»¤Ïß³ÌʹÓõÄÇé¿ö½ÏÉÙ£¬µ«²¢·ÇÎÞÓ㬾ÙÀýÀ´Ëµ£¬JVMµÄÀ¬»ø»ØÊÕ¡¢ÄÚ´æ¹ÜÀíµÈÏ̶߳¼ÊÇÊØ»¤Ï̡߳£»¹ÓоÍÊÇÔÚ×öÊý¾Ý¿âÓ¦ÓÃʱºò£¬Ê¹ÓõÄÊý¾Ý¿âÁ¬½Ó³Ø£¬Á¬½Ó³Ø±¾ÉíÒ²°üº ......
JavaỊ̈߳ºÏ̵߳Äͬ²½-ͬ²½¿é
¶ÔÓÚͬ²½£¬³ýÁËͬ²½·½·¨Í⣬»¹¿ÉÒÔʹÓÃͬ²½´úÂë¿é£¬ÓÐʱºòͬ²½´úÂë¿é»á´øÀ´±Èͬ²½·½·¨¸üºÃµÄЧ¹û¡£
×·Æäͬ²½µÄ¸ù±¾µÄÄ¿µÄ£¬ÊÇ¿ØÖƾºÕù×ÊÔ´µÄÕýÈ·µÄ·ÃÎÊ£¬Òò´ËÖ»ÒªÔÚ·ÃÎʾºÕù×ÊÔ´µÄʱºò±£Ö¤Í¬Ò»Ê±¿ÌÖ»ÄÜÒ»¸öÏ̷߳ÃÎʼ´¿É£¬Òò´ËJavaÒýÈëÁËͬ²½´úÂë¿ìµÄ²ßÂÔ£¬ÒÔÌá¸ßÐÔÄÜ¡£
&nb ......
JavaỊ̈߳ºÐÂÌØÕ÷-Ï̳߳Ø
SunÔÚJava5ÖУ¬¶ÔJavaÏ̵߳ÄÀà¿â×öÁË´óÁ¿µÄÀ©Õ¹£¬ÆäÖÐÏ̳߳ؾÍÊÇJava5µÄÐÂÌØÕ÷Ö®Ò»£¬³ýÁËÏ̳߳ØÖ®Í⣬»¹Óкܶà¶àÏß³ÌÏà¹ØµÄÄÚÈÝ£¬Îª¶àÏ̵߳ıà³Ì´øÀ´Á˼«´ó±ãÀû¡£ÎªÁ˱àд¸ßЧÎȶ¨¿É¿¿µÄ¶àÏ̳߳ÌÐò£¬Ï̲߳¿·ÖµÄÐÂÔöÄÚÈÝÏÔµÃÓÈΪÖØÒª¡£
ÓйØJava5Ïß³ÌÐÂÌØÕ÷µÄÄÚÈÝÈ«²¿ÔÚjava.util ......