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

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

JavaỊ̈߳ºvolatile¹Ø¼ü×Ö
 
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖƵÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£
 
̸¼°µ½volatile¹Ø¼ü×Ö£¬²»µÃ²»ÌáµÄһƪÎÄÕÂÊÇ£º¡¶Java ÀíÂÛÓëʵ¼ù: ÕýȷʹÓà Volatile ±äÁ¿¡·£¬ÕâƪÎÄÕ¶Ôvolatile¹Ø¼ü×ÖµÄÓ÷¨×öÁËÏ൱¾«±ÙµÄ²ûÊö¡£
 
Ö®ËùÒÔÒªµ¥¶ÀÌá³övolatileÕâ¸ö²»³£ÓõĹؼü×ÖÔ­ÒòÊÇÕâ¸ö¹Ø¼ü×ÖÔÚ¸ßÐÔÄܵĶàÏ̳߳ÌÐòÖÐÒ²ÓкÜÖØÒªµÄÓÃ;£¬Ö»ÊÇÕâ¸ö¹Ø¼ü×ÖÓò»ºÃ»á³öºÜ¶àÎÊÌâ¡£
 
Ê×ÏÈ¿¼ÂÇÒ»¸öÎÊÌ⣬Ϊʲô±äÁ¿ÐèÒªvolatileÀ´ÐÞÊÎÄØ£¿
Òª¸ãÇå³þÕâ¸öÎÊÌ⣬Ê×ÏÈÓ¦¸ÃÃ÷°×¼ÆËã»úÄÚ²¿¶¼×öʲôÁË¡£±ÈÈç×öÁËÒ»¸öi++²Ù×÷£¬¼ÆËã»úÄÚ²¿×öÁËÈý´Î´¦Àí£º¶ÁÈ¡£­Ð޸ģ­Ð´Èë¡£
ͬÑù£¬¶ÔÓÚÒ»¸ölongÐÍÊý¾Ý£¬×öÁ˸ö¸³Öµ²Ù×÷£¬ÔÚ32ϵͳÏÂÐèÒª¾­¹ýÁ½²½²ÅÄÜÍê³É£¬ÏÈÐ޸ĵÍ32λ£¬È»ºóÐ޸ĸß32λ¡£
 
¼ÙÏëһϣ¬µ±½«ÒÔÉϵIJÙ×÷·Åµ½Ò»¸ö¶àÏ̻߳·¾³Ï²Ù×÷ʱºò£¬ÓпÉÄܳöÏÖµÄÎÊÌ⣬ÊÇÕâЩ²½ÖèÖ´ÐÐÁËÒ»²¿·Ö£¬¶øÁíÍâÒ»¸öÏ߳̾ÍÒѾ­ÒýÓÃÁ˱äÁ¿Öµ£¬ÕâÑù¾Íµ¼ÖÂÁ˶ÁÈ¡ÔàÊý¾ÝµÄÎÊÌâ¡£
 
ͨ¹ýÕâ¸öÉèÏ룬¾Í²»ÄÑÀí½âvolatile¹Ø¼ü×ÖÁË¡£
 
volatile¿ÉÒÔÓÃÔÚÈκαäÁ¿Ç°Ã棬µ«²»ÄÜÓÃÓÚfinal±äÁ¿Ç°Ã棬ÒòΪfinalÐ͵ıäÁ¿ÊǽûÖ¹Ð޸ĵġ£Ò²²»´æÔÚḬ̈߳²È«µÄÎÊÌâ¡£
 
¸ü¶àµÄÄÚÈÝ£¬Çë²Î¿´£º£º¡¶Java ÀíÂÛÓëʵ¼ù: ÕýȷʹÓà Volatile ±äÁ¿¡·Ò»ÎÄ£¬Ð´µÃºÜºÃ¡£
 


Ïà¹ØÎĵµ£º

ʹÓÃ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¡¢À©Õ¹java.lang.ThreadÀà¡£
 
´ËÀàÖÐÓиörun()·½·¨£¬Ó¦¸Ã×¢ÒâÆäÓ÷¨£º
public void run()
Èç¹û¸ÃÏß³ÌÊÇʹÓöÀÁ¢µÄ Runnable ÔËÐжÔÏó¹¹ÔìµÄ£¬Ôòµ÷Óøà Runnable ¶ÔÏóµÄ run ·½·¨£»·ñÔò£¬¸Ã·½·¨²»Ö´ÐÐÈκβÙ×÷²¢·µ»Ø¡£
 
Thr ......

Java²Ù×÷Excel·½·¨±È½Ï

1. Java¶ÁÈ¡Excel·½Ê½¶Ô±È
ÔÚJavaÖжÁдMS ExcelÎļþÖ÷ÒªÓÐÁ½ÖÖµäÐ͵ķ½·¨
l         Java-To-ComµÄ·½Ê½£º
£¨£±£©   jCom
£¨£²£©   Jacob
l         Ö±½ÓExcelÎļþ¶Áд
£¨£³£©   jExcel
£¨£´£©&nbs ......

JavaỊ̈߳ºÏ̵߳ĵ÷¶È ÓÅÏȼ¶

JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÓÅÏȼ¶
 
ÓëÏß³ÌÐÝÃßÀàËÆ£¬Ï̵߳ÄÓÅÏȼ¶ÈÔÈ»ÎÞ·¨±£ÕÏÏ̵߳ÄÖ´ÐдÎÐò¡£Ö»²»¹ý£¬ÓÅÏȼ¶¸ßµÄÏ̻߳ñÈ¡CPU×ÊÔ´µÄ¸ÅÂʽϴó£¬ÓÅÏȼ¶µÍµÄ²¢·Çû»ú»áÖ´ÐС£
 
Ï̵߳ÄÓÅÏȼ¶ÓÃ1-10Ö®¼äµÄÕûÊý±íʾ£¬ÊýÖµÔ½´óÓÅÏȼ¶Ô½¸ß£¬Ä¬ÈϵÄÓÅÏȼ¶Îª5¡£
 
ÔÚÒ»¸öÏß³ÌÖпªÆôÁíÍâÒ»¸öÐÂỊ̈߳¬ÔòпªÏ̳߳ÆÎ ......

JavaỊ̈߳ºÏ̵߳ĵ÷¶È Èò½

JavaỊ̈߳ºÏ̵߳ĵ÷¶È-Èò½
 
Ï̵߳ÄÈò½º¬Òå¾ÍÊÇʹµ±Ç°ÔËÐÐ×ÅÏß³ÌÈóöCPU×ÊÔ´£¬µ«ÊÇÈ»¸øË­²»ÖªµÀ£¬½ö½öÊÇÈóö£¬Ïß³Ì״̬»Øµ½¿ÉÔËÐÐ״̬¡£
 
Ï̵߳ÄÈò½Ê¹ÓÃThread.yield()·½·¨£¬yield() Ϊ¾²Ì¬·½·¨£¬¹¦ÄÜÊÇÔÝÍ£µ±Ç°ÕýÔÚÖ´ÐеÄÏ̶߳ÔÏ󣬲¢Ö´ÐÐÆäËûÏ̡߳£
 
/**
* JavaỊ̈߳ºÏ̵߳ĵ÷¶È-Èò½
*
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ