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

JavaÄÚ´æÄ£ÐÍ

ÔÚÁ˽âJavaµÄͬ²½ÃØÃÜ֮ǰ£¬ÏÈÀ´¿´¿´JMM(Java Memory Model)¡£
Java±»Éè¼ÆΪ¿çƽ̨µÄÓïÑÔ£¬ÔÚÄÚ´æ¹ÜÀíÉÏ£¬ÏÔȻҲҪÓÐÒ»¸öͳһµÄÄ£ÐÍ¡£¶øÇÒJavaÓïÑÔ×î´óµÄÌصã¾ÍÊǷϳýÁËÖ¸Õ룬°Ñ³ÌÐòÔ±´ÓÍ´¿àÖнâÍѳöÀ´£¬²»ÓÃÔÙ¿¼ÂÇÄÚ´æʹÓú͹ÜÀí·½ÃæµÄÎÊÌâ¡£
¿ÉϧÊÀÊÂ×ܲ»¾¡ÈçÈËÒ⣬ËäÈ»JMMÉè¼ÆÉÏ·½±ãÁ˳ÌÐòÔ±£¬µ«ÊÇËüÔö¼ÓÁËÐéÄâ»úµÄ¸´Ôӳ̶ȣ¬¶øÇÒ»¹µ¼ÖÂijЩ±à³Ì¼¼ÇÉÔÚJavaÓïÑÔÖÐʧЧ¡£
JMMÖ÷ÒªÊÇΪÁ˹涨ÁËÏ̺߳ÍÄÚ´æÖ®¼äµÄһЩ¹Øϵ¡£¶ÔJava³ÌÐòÔ±À´ËµÖ»Ð踺ÔðÓÃsynchronizedͬ²½¹Ø¼ü×Ö£¬ÆäËüÖîÈçÓëÏß³Ì/ÄÚ´æÖ®¼ä½øÐÐÊý¾Ý½»»»/ͬ²½µÈ·±Ëö¹¤×÷¾ùÓÉÐéÄâ»ú¸ºÔðÍê³É¡£Èçͼ1Ëùʾ£º¸ù¾ÝJMMµÄÉè¼Æ£¬ÏµÍ³´æÔÚÒ»¸öÖ÷ÄÚ´æ(Main Memory)£¬JavaÖÐËùÓбäÁ¿¶¼´¢´æÔÚÖ÷´æÖУ¬¶ÔÓÚËùÓÐÏ̶߳¼Êǹ²ÏíµÄ¡£Ã¿ÌõÏ̶߳¼ÓÐ×Ô¼ºµÄ¹¤×÷ÄÚ´æ(Working Memory)£¬¹¤×÷ÄÚ´æÖб£´æµÄÊÇÖ÷´æÖÐijЩ±äÁ¿µÄ¿½±´£¬Ï̶߳ÔËùÓбäÁ¿µÄ²Ù×÷¶¼ÊÇÔÚ¹¤×÷ÄÚ´æÖнøÐУ¬Ïß³ÌÖ®¼äÎÞ·¨Ï໥ֱ½Ó·ÃÎÊ£¬±äÁ¿´«µÝ¾ùÐèҪͨ¹ýÖ÷´æÍê³É¡£
ͼ1 JavaÄÚ´æÄ£ÐÍʾÀýͼ
Ïß³ÌÈôÒª¶Ôij±äÁ¿½øÐвÙ×÷£¬±ØÐë¾­¹ýһϵÁв½Ö裺Ê×ÏÈ´ÓÖ÷´æ¸´ÖÆ/Ë¢ÐÂÊý¾Ýµ½¹¤×÷Äڴ棬ȻºóÖ´ÐдúÂ룬½øÐÐÒýÓÃ/¸³Öµ²Ù×÷£¬×îºó°Ñ±äÁ¿ÄÚÈÝд»ØMain Memory¡£JavaÓïÑԹ淶(JLS)ÖжÔÏ̺߳ÍÖ÷´æ»¥²Ù×÷¶¨ÒåÁË6¸öÐÐΪ£¬·Ö±ðΪload£¬save£¬read£¬write£¬assignºÍuse£¬ÕâЩ²Ù×÷ÐÐΪ¾ßÓÐÔ­×ÓÐÔ£¬ÇÒÏ໥ÒÀÀµ£¬ÓÐÃ÷È·µÄµ÷ÓÃÏȺó˳Ðò¡£¾ßÌåµÄÃèÊöÇë²Î¼ûJLSµÚ17Õ¡£
ÎÒÃÇÔÚÇ°ÃæµÄÕ½ڽéÉÜÁËsynchronizedµÄ×÷Óã¬ÏÖÔÚ£¬´ÓJMMµÄ½Ç¶ÈÀ´ÖØÐÂÉóÊÓsynchronized¹Ø¼ü×Ö¡£
¼ÙÉèijÌõÏß³ÌÖ´ÐÐÒ»¸ösynchronized´úÂë¶Î£¬Æä¼ä¶Ôij±äÁ¿½øÐвÙ×÷£¬JVM»áÒÀ´ÎÖ´ÐÐÈç϶¯×÷£º
(1) »ñȡͬ²½¶ÔÏómonitor (lock)
(2) ´ÓÖ÷´æ¸´ÖƱäÁ¿µ½µ±Ç°¹¤×÷ÄÚ´æ (read and load)
(3) Ö´ÐдúÂ룬¸Ä±ä¹²Ïí±äÁ¿Öµ (use and assign)
(4) Óù¤×÷ÄÚ´æÊý¾ÝË¢ÐÂÖ÷´æÏà¹ØÄÚÈÝ (store and write)
(5) ÊÍ·Åͬ²½¶ÔÏóËø (unlock)
¿É¼û£¬synchronizedµÄÁíÍâÒ»¸ö×÷ÓÃÊDZ£Ö¤Ö÷´æÄÚÈݺÍÏ̵߳Ť×÷ÄÚ´æÖеÄÊý¾ÝµÄÒ»ÖÂÐÔ¡£Èç¹ûûÓÐʹÓÃsynchronized¹Ø¼ü×Ö£¬JVM²»±£Ö¤µÚ2²½ºÍµÚ4²½»áÑϸñ°´ÕÕÉÏÊö´ÎÐòÁ¢¼´Ö´ÐС£ÒòΪ¸ù¾ÝJLSÖеĹ涨£¬Ï̵߳Ť×÷ÄÚ´æºÍÖ÷´æÖ®¼äµÄÊý¾Ý½»»»ÊÇËÉñîºÏµÄ£¬Ê²Ã´Ê±ºòÐèҪˢй¤×÷ÄÚ´æ»òÕ߸üÐÂÖ÷ÄÚ´æÄÚÈÝ£¬¿ÉÒÔÓɾßÌåµÄÐéÄâ»úʵÏÖ×ÔÐоö¶¨¡£Èç¹û¶à¸öÏß³ÌͬʱִÐÐÒ»¶Îδ¾­synchronized±£»¤µÄ´úÂë¶Î£¬ºÜÓпÉÄÜijÌõÏß³ÌÒѾ­¸Ä¶¯Á˱äÁ¿µÄÖµ£¬µ«ÊÇÆäËûÏß³ÌÈ´ÎÞ·¨¿´µ½Õâ¸ö¸Ä¶¯£¬ÒÀÈ»ÔھɵÄ


Ïà¹ØÎĵµ£º

¡¾×ª¡¿Ãô½Ý¿ª·¢Öбàд¸ßÖÊÁ¿Java´úÂë

Ãô½Ý¿ª·¢µÄÀíÄîÒѾ­Á÷ÐÐÁ˺ܳ¤µÄʱ¼ä£¬ÔÚÃô½Ý¿ª·¢ÖеĿª·¢µü´ú½×¶ÎÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÎå¸ö²½Ö裬À´ÓÐЧµÄÌá¸ßÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿¡£
JavaÏîÄ¿¿ª·¢¹ý³ÌÖУ¬ÓÉÓÚ¿ª·¢ÈËÔ±µÄ¾­Ñé¡¢Java´úÂë±àдϰ¹ß£¬ÒÔ¼°È±·¦Í³Ò»µÄ±ê×¼ºÍ¹ÜÀíÁ÷³Ì£¬ÍùÍùµ¼ÖÂÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿½Ï²î£¬ÄÑÓÚά
»¤£¬ÐèÒª½Ï´óµÄ²âÊÔͶÈëºÍÖÜÆÚµÈÎÊÌâ¡£ÕâЩÎÊÌâÔÚÒ»¸ ......

[ת]JavaScriptºÍJavaµÄÇø±ð

JavaScriptºÍJavaµÄÇø±ð
¡¡¡¡ËäÈ»JavaScriptÓëJavaÓнôÃܵÄÁªÏµ£¬µ«È´ÊÇÁ½¸ö¹«Ë¾¿ª·¢µÄ²»Í¬µÄÁ½¸ö²úÆ·¡£JavaÊÇSUN¹«Ë¾ÍƳöµÄÐÂÒ»´úÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÓïÑÔ£¬ÌرðÊʺÏÓÚInternetÓ¦ÓóÌÐò¿ª·¢£»¶øJavaScriptÊÇNetscape¹«Ë¾µÄ²úÆ·£¬ÆäÄ¿µÄÊÇΪÁËÀ©Õ¹Netscape Navigator¹¦ÄÜ,¶ø¿ª·¢µÄÒ»ÖÖ¿ÉÒÔǶÈëWebÒ³ÃæÖеĻùÓÚ¶ÔÏóºÍʼþÇý¶ ......

javaʹÓÃPOI²Ù×÷Excel±¨±í

HSSFWorkbook API£ºhttp://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFWorkbook.html
office°ì¹«Èí¼þµÄʹÓÃʹµÃ¿ª·¢ÆóÒµ°ì¹«ÏµÍ³ÖУ¬³£³£Óпͻ§ÕâÑù×ÓÒªÇó£ºÄãÒª°ÑÎÒÃǵı¨±íÖ±½ÓÓÃExcel´ò¿ª¡£»òÕßÊÇ£ºÎÒÃÇÒѾ­Ï°¹ßÓÃExcel´òÓ¡¡£ÕâÑù×ÓÈç¹ûÓÃ.net¿ª·¢ÊÇûÓÐÎÊÌâµÄ£¬µ«ÊÇÓÐj2eeÕâ¸ö±È.net¸üÓÐǰ;µÄ¿ª·Åʽµ ......

JavaỊ̈߳º¸ÅÄîÓëÔ­Àí


JavaỊ̈߳º¸ÅÄîÓëÔ­Àí
 
SCJP5ѧϰ±Ê¼Ç
 
Ò»¡¢²Ù×÷ϵͳÖÐÏ̺߳ͽø³ÌµÄ¸ÅÄî
ÏÖÔڵIJÙ×÷ϵͳÊǶàÈÎÎñ²Ù×÷ϵͳ¡£¶àÏß³ÌÊÇʵÏÖ¶àÈÎÎñµÄÒ»ÖÖ·½Ê½¡£
½ø³ÌÊÇÖ¸Ò»¸öÄÚ´æÖÐÔËÐеÄÓ¦ÓóÌÐò£¬Ã¿¸ö½ø³Ì¶¼ÓÐ×Ô¼º¶ÀÁ¢µÄÒ»¿éÄÚ´æ¿Õ¼ä£¬Ò»¸ö½ø³ÌÖпÉÒÔÆô¶¯¶à¸öÏ̡߳£±ÈÈçÔÚWindowsϵͳÖУ¬Ò»¸öÔËÐеÄexe¾ÍÊÇÒ»¸ö½ø³Ì¡£
& ......

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

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