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

JavaỊ̈߳ºÐÂÌØÕ÷ Ô­×ÓÁ¿

JavaỊ̈߳ºÐÂÌØÕ÷-Ô­×ÓÁ¿
 
ËùνµÄÔ­×ÓÁ¿¼´²Ù×÷±äÁ¿µÄ²Ù×÷ÊǓԭ×ӵĔ£¬¸Ã²Ù×÷²»¿ÉÔÙ·Ö£¬Òò´ËÊÇḬ̈߳²È«µÄ¡£
 
ΪºÎҪʹÓÃÔ­×Ó±äÁ¿ÄØ£¬Ô­ÒòÊǶà¸öÏ̶߳Ե¥¸ö±äÁ¿²Ù×÷Ò²»áÒýÆðһЩÎÊÌâ¡£ÔÚJava5֮ǰ£¬¿ÉÒÔͨ¹ývolatile¡¢synchronized¹Ø¼ü×ÖÀ´½â¾ö²¢·¢·ÃÎʵݲȫÎÊÌ⣬µ«ÕâÑùÌ«Âé·³¡£
Java5Ö®ºó£¬×¨ÃÅÌṩÁËÓÃÀ´½øÐе¥±äÁ¿¶àÏ̲߳¢·¢°²È«·ÃÎʵŤ¾ß°üjava.util.concurrent.atomic£¬ÆäÖеÄÀàÒ²ºÜ¼òµ¥¡£
 
ÏÂÃæ¸ø³öÒ»¸ö·´ÃæÀý×Ó£¨ÇÐÎðÄ£·Â£©£º
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
/**
* JavaỊ̈߳ºÐÂÌØÕ÷-Ô­×ÓÁ¿
*
* @author leizhimin 2009-11-6 9:53:11
*/
public class Test {
        public static void main(String[] args) {
                ExecutorService pool = Executors.newFixedThreadPool(2);
                Runnable t1 = new MyRunnable("ÕÅÈý", 2000);
                Runnable t2 = new MyRunnable("ÀîËÄ", 3600);
                Runnable t3 = new MyRunnable("ÍõÎå", 2700);
                Runnable t4 = new MyRunnable("ÀÏÕÅ", 600);
                Runnable t5 = new MyRunnable("ÀÏÅ£", 1300);
                Runnable t6 = new MyRunnable("ÅÖ×Ó", 800);
                //Ö´Ðи÷¸öÏß³Ì
                pool.execute


Ïà¹ØÎĵµ£º

JavaỊ̈߳ºÏ̵߳ĵ÷¶È ºÏ²¢

JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ºÏ²¢
 
Ï̵߳ĺϲ¢µÄº¬Òå¾ÍÊǽ«¼¸¸ö²¢ÐÐÏ̵߳ÄÏ̺߳ϲ¢ÎªÒ»¸öµ¥Ïß³ÌÖ´ÐУ¬Ó¦Óó¡¾°Êǵ±Ò»¸öÏ̱߳ØÐëµÈ´ýÁíÒ»¸öÏß³ÌÖ´ÐÐÍê±Ï²ÅÄÜÖ´ÐÐʱ¿ÉÒÔʹÓÃjoin·½·¨¡£
 
joinΪ·Ç¾²Ì¬·½·¨£¬¶¨ÒåÈçÏ£º
void join()    
    µÈ´ý¸ÃÏß³ÌÖÕÖ¹¡£   ......

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

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

JavaỊ̈߳ºÏ̵߳Äͬ²½ ͬ²½¿é

JavaỊ̈߳ºÏ̵߳Äͬ²½-ͬ²½¿é
 
¶ÔÓÚͬ²½£¬³ýÁËͬ²½·½·¨Í⣬»¹¿ÉÒÔʹÓÃͬ²½´úÂë¿é£¬ÓÐʱºòͬ²½´úÂë¿é»á´øÀ´±Èͬ²½·½·¨¸üºÃµÄЧ¹û¡£
 
×·Æäͬ²½µÄ¸ù±¾µÄÄ¿µÄ£¬ÊÇ¿ØÖƾºÕù×ÊÔ´µÄÕýÈ·µÄ·ÃÎÊ£¬Òò´ËÖ»ÒªÔÚ·ÃÎʾºÕù×ÊÔ´µÄʱºò±£Ö¤Í¬Ò»Ê±¿ÌÖ»ÄÜÒ»¸öÏ̷߳ÃÎʼ´¿É£¬Òò´ËJavaÒýÈëÁËͬ²½´úÂë¿ìµÄ²ßÂÔ£¬ÒÔÌá¸ßÐÔÄÜ¡£
&nb ......

Eclipse Java×¢ÊÍÄ£°åÉèÖÃÏê½â


ÉèÖÃ×¢ÊÍÄ£°åµÄÈë¿Ú£º Window->Preference->Java->Code Style->Code Template È»ºóÕ¹¿ªComments½Úµã¾ÍÊÇËùÓÐÐèÉèÖÃ×¢Ê͵ÄÔªËØÀ²¡£ÏÖ¾Íÿһ¸öÔªËØÖðÒ»½éÉÜ£º
Îļþ(Files)×¢ÊͱêÇ©£º
/**   
* @Title: ${file_name}
* @Package ${package_name}
* @Description: ${todo}(ÓÃÒ»¾ä»°ÃèÊö¸ÃÎļ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ