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

JavaỊ̈߳ºÐÂÌØÕ÷ ×èÈû¶ÓÁÐ

JavaỊ̈߳ºÐÂÌØÕ÷-×èÈû¶ÓÁÐ
 
×èÈû¶ÓÁÐÊÇJava5Ïß³ÌÐÂÌØÕ÷ÖеÄÄÚÈÝ£¬Java¶¨ÒåÁË×èÈû¶ÓÁеĽӿÚjava.util.concurrent.BlockingQueue£¬×èÈû¶ÓÁеĸÅÄîÊÇ£¬Ò»¸öÖ¸¶¨³¤¶ÈµÄ¶ÓÁУ¬Èç¹û¶ÓÁÐÂúÁË£¬Ìí¼ÓÐÂÔªËصIJÙ×÷»á±»×èÈûµÈ´ý£¬Ö±µ½ÓпÕλΪֹ¡£Í¬Ñù£¬µ±¶ÓÁÐΪ¿Õʱºò£¬ÇëÇó¶ÓÁÐÔªËصIJÙ×÷ͬÑù»á×èÈûµÈ´ý£¬Ö±µ½ÓпÉÓÃÔªËØΪֹ¡£
 
ÓÐÁËÕâÑùµÄ¹¦ÄÜ£¬¾ÍΪ¶àÏ̵߳ÄÅŶӵȺòµÄÄ£ÐÍʵÏÖ¿ª±ÙÁ˱ã½ÝͨµÀ£¬·Ç³£ÓÐÓá£
 
java.util.concurrent.BlockingQueue¼Ì³ÐÁËjava.util.Queue½Ó¿Ú£¬¿ÉÒԲο´APIÎĵµ¡£
 
ÏÂÃæ¸ø³öÒ»¸ö¼òµ¥Ó¦ÓõÄÀý×Ó£º
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ArrayBlockingQueue;
/**
* JavaỊ̈߳ºÐÂÌØÕ÷-×èÈû¶ÓÁÐ
*
* @author leizhimin 2009-11-5 14:59:15
*/
public class Test {
        public static void main(String[] args) throws InterruptedException {
                BlockingQueue bqueue = new ArrayBlockingQueue(20);
                for (int i = 0; i < 30; i++) {
                        //½«Ö¸¶¨ÔªËØÌí¼Óµ½´Ë¶ÓÁÐÖУ¬Èç¹ûûÓпÉÓÿռ䣬½«Ò»Ö±µÈ´ý£¨Èç¹ûÓбØÒª£©¡£
                        bqueue.put(i);
                        System.out.println("Ïò×èÈû¶ÓÁÐÖÐÌí¼ÓÁËÔªËØ:" + i);
                }
                System.out.println("³ÌÐòµ½´ËÔËÐнáÊø£¬¼´½«Í˳ö----");
        }
}


Ïà¹ØÎĵµ£º

JavaỊ̈߳ºÏ̵߳Ľ»»¥

JavaỊ̈߳ºÏ̵߳Ľ»»¥
 
SCJP5ѧϰ±Ê¼Ç
 
Ï߳̽»»¥ÊDZȽϸ´ÔÓµÄÎÊÌ⣬SCJPÒªÇ󲻺ܻù´¡£º¸ø¶¨Ò»¸ö³¡¾°£¬±àд´úÂëÀ´Ç¡µ±Ê¹Óõȴý¡¢Í¨ÖªºÍ֪ͨËùÓÐÏ̡߳£
 
Ò»¡¢Ï߳̽»»¥µÄ»ù´¡ÖªÊ¶
 
SCJPËùÒªÇóµÄÏ߳̽»»¥ÖªÊ¶µãÐèÒª´Ójava.lang.ObjectµÄÀàµÄÈý¸ö·½·¨À´Ñ§Ï°£º
 
 void notify()
......

JavaỊ̈߳ºÏ̵߳ĵ÷¶È ÐÝÃß

JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÐÝÃß
 
JavaÏ̵߳÷¶ÈÊÇJava¶àÏ̵߳ĺËÐÄ£¬Ö»ÓÐÁ¼ºÃµÄµ÷¶È£¬²ÅÄܳä·Ö·¢»ÓϵͳµÄÐÔÄÜ£¬Ìá¸ß³ÌÐòµÄÖ´ÐÐЧÂÊ¡£
 
ÕâÀïÒªÃ÷È·µÄÒ»µã£¬²»¹Ü³ÌÐòÔ±Ôõô±àдµ÷¶È£¬Ö»ÄÜ×î´óÏ޶ȵÄÓ°ÏìÏß³ÌÖ´ÐеĴÎÐò£¬¶ø²»ÄÜ×öµ½¾«×¼¿ØÖÆ¡£
 
Ïß³ÌÐÝÃßµÄÄ¿µÄÊÇʹÏß³ÌÈóöCPUµÄ×î¼òµ¥µÄ×ö·¨Ö®Ò»£¬Ïß³ÌÐÝÃß ......

JavaỊ̈߳ºÏ̵߳ĵ÷¶È ÊØ»¤Ïß³Ì

JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÊØ»¤Ïß³Ì
 
ÊØ»¤Ïß³ÌÓëÆÕͨÏß³Ìд·¨ÉÏ»ù±¾Ã´É¶Çø±ð£¬µ÷ÓÃÏ̶߳ÔÏóµÄ·½·¨setDaemon(true)£¬Ôò¿ÉÒÔ½«ÆäÉèÖÃΪÊØ»¤Ï̡߳£
 
ÊØ»¤Ïß³ÌʹÓõÄÇé¿ö½ÏÉÙ£¬µ«²¢·ÇÎÞÓ㬾ÙÀýÀ´Ëµ£¬JVMµÄÀ¬»ø»ØÊÕ¡¢ÄÚ´æ¹ÜÀíµÈÏ̶߳¼ÊÇÊØ»¤Ï̡߳£»¹ÓоÍÊÇÔÚ×öÊý¾Ý¿âÓ¦ÓÃʱºò£¬Ê¹ÓõÄÊý¾Ý¿âÁ¬½Ó³Ø£¬Á¬½Ó³Ø±¾ÉíÒ²°üº ......

JavaỊ̈߳ºvolatile¹Ø¼ü×Ö

JavaỊ̈߳ºvolatile¹Ø¼ü×Ö
 
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖƵÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£
 
̸¼°µ½volatile¹Ø¼ü×Ö£¬²»µÃ²»ÌáµÄһƪÎÄÕÂÊÇ£º¡¶Java ......

JavaỊ̈߳ºÐÂÌØÕ÷ Ëø£¨Ï£©

JavaỊ̈߳ºÐÂÌØÕ÷-Ëø£¨Ï£©
 
ÔÚÉÏÎÄÖÐÌáµ½ÁËLock½Ó¿ÚÒÔ¼°¶ÔÏó£¬Ê¹ÓÃËü£¬ºÜÓÅÑŵĿØÖÆÁ˾ºÕù×ÊÔ´µÄ°²È«·ÃÎÊ£¬µ«ÊÇÕâÖÖËø²»Çø·Ö¶Áд£¬³ÆÕâÖÖËøΪÆÕͨËø¡£ÎªÁËÌá¸ßÐÔÄÜ£¬JavaÌṩÁ˶ÁдËø£¬ÔÚ¶ÁµÄµØ·½Ê¹ÓöÁËø£¬ÔÚдµÄµØ·½Ê¹ÓÃдËø£¬Áé»î¿ØÖÆ£¬ÔÚÒ»¶¨³Ì¶ÈÉÏÌá¸ßÁ˳ÌÐòµÄÖ´ÐÐЧÂÊ¡£
 
JavaÖжÁдËøÓиö½Ó¿Újava ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ