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

JavaỊ̈߳ºÐÂÌØÕ÷ Óзµ»ØÖµµÄÏß³Ì

JavaỊ̈߳ºÐÂÌØÕ÷-Óзµ»ØÖµµÄÏß³Ì
 
ÔÚJava5֮ǰ£¬Ïß³ÌÊÇûÓзµ»ØÖµµÄ£¬³£³£ÎªÁË“ÓД·µ»ØÖµ£¬ÆÆ·ÑÖÜÕÛ£¬¶øÇÒ´úÂëºÜ²»ºÃд¡£»òÕ߸ɴàÈƹýÕâµÀ¿²£¬×ß±ðµÄ·ÁË¡£
 
ÏÖÔÚJavaÖÕÓÚÓпɷµ»ØÖµµÄÈÎÎñ£¨Ò²¿ÉÒÔ½Ð×öỊ̈߳©ÁË¡£
 
¿É·µ»ØÖµµÄÈÎÎñ±ØÐëʵÏÖCallable½Ó¿Ú£¬ÀàËƵģ¬ÎÞ·µ»ØÖµµÄÈÎÎñ±ØÐëRunnable½Ó¿Ú¡£
 
Ö´ÐÐCallableÈÎÎñºó£¬¿ÉÒÔ»ñÈ¡Ò»¸öFutureµÄ¶ÔÏó£¬ÔڸöÔÏóÉϵ÷ÓÃget¾Í¿ÉÒÔ»ñÈ¡µ½CallableÈÎÎñ·µ»ØµÄObjectÁË¡£
 
ÏÂÃæÊǸöºÜ¼òµ¥µÄÀý×Ó£º
 
import java.util.concurrent.*;
/**
* JavaỊ̈߳ºÓзµ»ØÖµµÄÏß³Ì
*
* @author Administrator 2009-11-5 0:41:50
*/
public class Test {
        public static void main(String[] args) throws ExecutionException, InterruptedException {
                //´´½¨Ò»¸öÏ̳߳Ø
                ExecutorService pool = Executors.newFixedThreadPool(2);
                //´´½¨Á½¸öÓзµ»ØÖµµÄÈÎÎñ
                Callable c1 = new MyCallable("A");
                Callable c2 = new MyCallable("B");
                //Ö´ÐÐÈÎÎñ²¢»ñÈ¡Future¶ÔÏó
                Future f1 = pool.submit(c1);
                Future f2 = pool.submit(c2);
                //´ÓFuture¶ÔÏóÉÏ»ñÈ¡ÈÎÎñµÄ·µ»ØÖµ£¬²¢Êä³öµ½¿ØÖÆ̨
           &


Ïà¹ØÎĵµ£º

ʹÓÃeclipseÔËÐÐÔø¾­Ð´¹ýµÄjava´úÂë

½ñÌì°ÑÒÔǰдµÄjava´úÂëÄóöÀ´£¬·¢ÏÖ³öÁ˺öà´íÎó¡£µ÷ÁË°ëÌ죬·¢ÏÖÊÇ°æ±¾µÄÎÊÌ⣬ÓôÃÆ£¡
¿ÉÄÜ֮ǰÎÒд´úÂëµÄʱºòÓõÄÊÇJDK1.5£¬½ñÌì´ÓÍøÉÏÏÂÔØJDK1.6£¬Ã»³É¹¦¡£¾Í²Ý²ÝÏÂÔØÁËJDK1.5,½á¹û×ÜÊÇÌáʾ“could not find the main class. program will exit”¡£ÎҾ͵½
window-¡·preference-¡·java-¡·compiler°Ñµ±Ç°µÄ°æ ......

JavaỊ̈߳ºÏß³Ì״̬µÄת»»

JavaỊ̈߳ºÏß³Ì״̬µÄת»»
 
SCJP5ѧϰ±Ê¼Ç
 
Ò»¡¢Ïß³Ì״̬
 
Ï̵߳Ä״̬ת»»ÊÇÏ߳̿ØÖƵĻù´¡¡£Ïß³Ì״̬×ܵĿɷÖΪÎå´ó״̬£º·Ö±ðÊÇÉú¡¢ËÀ¡¢¿ÉÔËÐС¢ÔËÐС¢µÈ´ý/×èÈû¡£ÓÃÒ»¸öͼÀ´ÃèÊöÈçÏ£º
 
1¡¢ÐÂ״̬£ºÏ̶߳ÔÏóÒѾ­´´½¨£¬»¹Ã»ÓÐÔÚÆäÉϵ÷ÓÃstart()·½·¨¡£
 
2¡¢¿ÉÔËÐÐ״̬£ºµ±Ïß³ÌÓÐ× ......

JavaỊ̈߳ºÏ̵߳Äͬ²½ÓëËø

JavaỊ̈߳ºÏ̵߳Äͬ²½ÓëËø
 
 
 
Ò»¡¢Í¬²½ÎÊÌâÌá³ö
 
Ï̵߳Äͬ²½ÊÇΪÁË·ÀÖ¹¶à¸öÏ̷߳ÃÎÊÒ»¸öÊý¾Ý¶ÔÏóʱ£¬¶ÔÊý¾ÝÔì³ÉµÄÆÆ»µ¡£
ÀýÈ磺Á½¸öÏß³ÌThreadA¡¢ThreadB¶¼²Ù×÷ͬһ¸ö¶ÔÏóFoo¶ÔÏ󣬲¢ÐÞ¸ÄFoo¶ÔÏóÉϵÄÊý¾Ý¡£
 
public class Foo {
    private int x = 100;
......

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

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

JavaỊ̈߳ºÐÂÌØÕ÷ Ï̳߳Ø

JavaỊ̈߳ºÐÂÌØÕ÷-Ï̳߳Ø
 
SunÔÚJava5ÖУ¬¶ÔJavaÏ̵߳ÄÀà¿â×öÁË´óÁ¿µÄÀ©Õ¹£¬ÆäÖÐÏ̳߳ؾÍÊÇJava5µÄÐÂÌØÕ÷Ö®Ò»£¬³ýÁËÏ̳߳ØÖ®Í⣬»¹Óкܶà¶àÏß³ÌÏà¹ØµÄÄÚÈÝ£¬Îª¶àÏ̵߳ıà³Ì´øÀ´Á˼«´ó±ãÀû¡£ÎªÁ˱àд¸ßЧÎȶ¨¿É¿¿µÄ¶àÏ̳߳ÌÐò£¬Ï̲߳¿·ÖµÄÐÂÔöÄÚÈÝÏÔµÃÓÈΪÖØÒª¡£
 
ÓйØJava5Ïß³ÌÐÂÌØÕ÷µÄÄÚÈÝÈ«²¿ÔÚjava.util ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ