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

Java ÀíÂÛÓëʵ¼ù: ÕýȷʹÓà Volatile ±äÁ¿

 
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖƵÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£ÔÚÕâÆÚµÄ Java ÀíÂÛÓëʵ¼ù
ÖУ¬Brian Goetz ½«½éÉܼ¸ÖÖÕýȷʹÓà volatile ±äÁ¿µÄģʽ£¬²¢Õë¶ÔÆäÊÊÓÃÐÔÏÞÖÆÌá³öһЩ½¨Òé¡£

Java ÓïÑÔÖÐµÄ volatile ±äÁ¿¿ÉÒÔ±»¿´×÷ÊÇÒ»ÖÖ “³Ì¶È½ÏÇáµÄ synchronized
”£»Óë synchronized
¿éÏà±È£¬volatile ±äÁ¿ËùÐèµÄ±àÂë½ÏÉÙ£¬²¢ÇÒÔËÐÐʱ¿ªÏúÒ²½ÏÉÙ£¬µ«ÊÇËüËùÄÜʵÏֵŦÄÜÒ²½öÊÇ synchronized
µÄÒ»²¿·Ö¡£±¾ÎĽéÉÜÁ˼¸ÖÖÓÐЧʹÓà volatile ±äÁ¿µÄģʽ£¬²¢Ç¿µ÷Á˼¸ÖÖ²»ÊʺÏʹÓà volatile ±äÁ¿µÄÇéÐΡ£
ËøÌṩÁËÁ½ÖÖÖ÷ÒªÌØÐÔ£º»¥³â£¨mutual exclusion£©
ºÍ¿É¼ûÐÔ£¨visibility£©
¡£
»¥³â¼´Ò»´ÎÖ»ÔÊÐíÒ»¸öÏ̳߳ÖÓÐij¸öÌض¨µÄËø£¬Òò´Ë¿ÉʹÓøÃÌØÐÔʵÏÖ¶Ô¹²ÏíÊý¾ÝµÄЭµ÷·ÃÎÊЭÒ飬ÕâÑù£¬Ò»´Î¾ÍÖ»ÓÐÒ»¸öÏß³ÌÄܹ»Ê¹Óøù²ÏíÊý¾Ý¡£¿É¼ûÐÔÒª¸ü¼Ó
¸´ÔÓһЩ£¬Ëü±ØÐëÈ·±£ÊÍ·ÅËø֮ǰ¶Ô¹²ÏíÊý¾Ý×ö³öµÄ¸ü¸Ä¶ÔÓÚËæºó»ñµÃ¸ÃËøµÄÁíÒ»¸öÏß³ÌÊǿɼûµÄ ——
Èç¹ûûÓÐͬ²½»úÖÆÌṩµÄÕâÖֿɼûÐÔ±£Ö¤£¬Ï߳̿´µ½µÄ¹²Ïí±äÁ¿¿ÉÄÜÊÇÐÞ¸ÄÇ°µÄÖµ»ò²»Ò»ÖµÄÖµ£¬Õ⽫Òý·¢Ðí¶àÑÏÖØÎÊÌâ¡£
Volatile ±äÁ¿
Volatile ±äÁ¿¾ßÓÐ synchronized
µÄ¿É¼ûÐÔÌØÐÔ£¬µ«ÊDz»¾ß±¸Ô­×ÓÌØÐÔ¡£Õâ¾ÍÊÇ˵Ïß³ÌÄܹ»×Ô¶¯·¢ÏÖ volatile ±äÁ¿µÄ×îÐÂÖµ¡£Volatile
±äÁ¿¿ÉÓÃÓÚÌṩḬ̈߳²È«£¬µ«ÊÇÖ»ÄÜÓ¦ÓÃÓڷdz£ÓÐÏÞµÄÒ»×éÓÃÀý£º¶à¸ö±äÁ¿Ö®¼ä»òÕßij¸ö±äÁ¿µÄµ±Ç°ÖµÓëÐ޸ĺóÖµÖ®¼äûÓÐÔ¼Êø¡£Òò´Ë£¬µ¥¶ÀʹÓÃ
volatile »¹²»×ãÒÔʵÏÖ¼ÆÊýÆ÷¡¢»¥³âËø»òÈκξßÓÐÓë¶à¸ö±äÁ¿Ïà¹ØµÄ²»±äʽ£¨Invariants£©µÄÀࣨÀýÈç “start
<=end”£©¡£
³öÓÚ¼òÒ×ÐÔ»ò¿ÉÉìËõÐԵĿ¼ÂÇ£¬Äú¿ÉÄÜÇãÏòÓÚʹÓà volatile ±äÁ¿¶ø²»ÊÇËø¡£µ±Ê¹ÓÃ
volatile ±äÁ¿¶ø·ÇËøʱ£¬Ä³Ð©Ï°¹ßÓ÷¨£¨idiom£©¸ü¼ÓÒ×ÓÚ±àÂëºÍÔĶÁ¡£´ËÍ⣬volatile
±äÁ¿²»»áÏñËøÄÇÑùÔì³ÉÏß³Ì×èÈû£¬Òò´ËÒ²ºÜÉÙÔì³É¿ÉÉìËõÐÔÎÊÌâ¡£ÔÚijЩÇé¿öÏ£¬Èç¹û¶Á²Ù×÷Ô¶Ô¶´óÓÚд²Ù×÷£¬volatile
±äÁ¿»¹¿ÉÒÔÌṩÓÅÓÚËøµÄÐÔÄÜÓÅÊÆ¡£
ÕýȷʹÓà volatile ±äÁ¿µÄÌõ¼þ
ÄúÖ»ÄÜÔÚÓÐÏÞµÄһЩÇéÐÎÏÂʹÓà volatile ±äÁ¿Ìæ´úËø¡£ÒªÊ¹ volatile ±äÁ¿ÌṩÀíÏëµÄḬ̈߳²È«£¬±ØÐëͬʱÂú×ãÏÂÃæÁ½¸öÌõ¼þ£º
¶Ô±äÁ¿µÄд²Ù×÷²»ÒÀÀµÓÚµ±Ç°Öµ¡£
¸Ã±äÁ¿Ã»Óаüº¬ÔÚ¾ßÓÐÆäËû±äÁ¿µÄ²»±äʽÖС£
ʵ¼ÊÉÏ£¬Õâ


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

´«ÖDz¥¿Íjavaѧϰ4

½ñÌìÎÒѧϰÁË·´ÉäÓë¶àÏ̵߳Ä֪ʶ
 
·´É䣺Class cls1=Date.class//×Ö½ÚÂë1£»
         Class cls2=Person.class//×Ö½ÚÂë2£»
 
P1.getClass();//µÃµ½×Ö½ÚÂë
Class.forName(“java.lang.String”) //µÃµ½Õâ¸öÀàµÄ×Ö½ÚÂë
 
ºǫ́Ïß³ÌÓëÁªºÏÏß³Ì
l & ......

phpºÍjava¹ØÓÚĿ¼Ê÷£¨ÁгöijһĿ¼ÏÂÎļþ½á¹¹£©

javaµÄд·¨
/**
*
* @param location
* @param nameList±£´æ½á¹ûµÄ£¡
*/
public void listDict(String location, List<String> nameList) {
File fileList = new File(location);
if (fileList.isDirectory()) {
File[] files = fileList.listFiles();
for (File f : files) {
i ......

java×Ö½ÚÁ÷¡¢×Ö·ûÁ÷

 
Java
Á÷²Ù×÷
 
¶ÔÓÚÎÒÃdz£ÓõÄGBKÖУ¬Ó¢ÎÄÊÇÕ¼ÓÃ1¸ö×Ö½Ú£¬ÖÐÎÄÊÇ2¸ö
¶ÔÓÚUTF-8£¬Ó¢ÎÄÊÇ1¸ö£¬ÖÐÎÄÊÇ3¸ö
¶ÔÓÚUnicode£¬Ó¢ÎÄÖÐÎĶ¼ÊÇ2¸ö
 
Java
µÄÁ÷²Ù×÷·ÖΪ×Ö½ÚÁ÷ºÍ×Ö·ûÁ÷Á½ÖÖ¡£
1¡¢
 
×Ö½ÚÁ÷
ËùÓеĶÁ²Ù×÷¶¼¼Ì³Ð×ÔÒ»¸ö¹«¹²³¬Àà
java
.io.InputStream
Àà¡£
ËùÓеÄд²Ù×÷¶¼¼Ì³Ð×ÔÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ