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

Java synchronizedÓ÷¨

synchronized¹Ø¼ü×ÖÔÚ¶àÏß³ÌÖеÄ×÷Óãº
Á½ÖÖÓ÷¨£ºsynchronized ·½·¨ºÍ synchronized ¿é¡£
1. synchronized ·½·¨£ºÍ¨¹ýÔÚ·½·¨ÉùÃ÷ÖмÓÈë synchronized¹Ø¼ü×ÖÀ´ÉùÃ÷ synchronized ·½·¨¡£ÈçÉÏÊöÀý×ÓËùÊö¡£
synchronized ·½·¨¿ØÖƶÔÀà³ÉÔ±±äÁ¿µÄ·ÃÎÊ£ºÃ¿¸öÀàʵÀý¶ÔÏó¶ÔÓ¦Ò»°ÑËø£¬Ã¿¸ö synchronized ·½·¨¶¼±ØÐë»ñµÃµ÷Óø÷½·¨µÄÀàʵÀý¶ÔÏóµÄËø·½ÄÜÖ´ÐУ¬·ñÔòËùÊôÏß³Ì×èÈû£¬·½·¨Ò»µ©Ö´ÐУ¬¾Í¶ÀÕ¼¸ÃËø£¬Ö±µ½´Ó¸Ã·½·¨·µ»Øʱ²Å½«ËøÊÍ·Å£¬´Ëºó±»×èÈûµÄÏ̷߳½ÄÜ»ñµÃ¸ÃËø£¬ÖØнøÈë¿ÉÖ´ÐÐ״̬¡£ÕâÖÖ»úÖÆÈ·±£ÁËͬһʱ¿Ì¶ÔÓÚÿһ¸öÀàʵÀý¶ÔÏó£¬ÆäËùÓÐÉùÃ÷Ϊ synchronized µÄ³ÉÔ±·½·¨ÖÐÖÁ¶àÖ»ÓÐÒ»¸ö´¦ÓÚ¿ÉÖ´ÐÐ״̬£¨ÒòΪÖÁ¶àÖ»ÓÐÒ»¸öÄܹ»»ñµÃ¸ÃÀàʵÀý¶ÔÏó¶ÔÓ¦µÄËø£©£¬´Ó¶øÓÐЧ±ÜÃâÁËÀà³ÉÔ±±äÁ¿µÄ·ÃÎʳåÍ»£¨Ö»ÒªËùÓпÉÄÜ·ÃÎÊÀà³ÉÔ±±äÁ¿µÄ·½·¨¾ù±»ÉùÃ÷Ϊ synchronized£©¡£
ÔÚ Java ÖУ¬²»¹âÊÇÀàʵÀý£¬Ã¿Ò»¸öÀàÒ²¶ÔÓ¦Ò»°ÑËø£¬ÕâÑùÎÒÃÇÒ²¿É½«ÀàµÄ¾²Ì¬³ÉÔ±º¯ÊýÉùÃ÷Ϊ synchronized £¬ÒÔ¿ØÖÆÆä¶ÔÀàµÄ¾²Ì¬³ÉÔ±±äÁ¿µÄ·ÃÎÊ¡£
synchronized ·½·¨µÄȱÏÝ£ºÈô½«Ò»¸ö´óµÄ·½·¨ÉùÃ÷Ϊsynchronized ½«»á´ó´óÓ°ÏìЧÂÊ£¬µäÐ͵أ¬Èô½«Ïß³ÌÀàµÄ·½·¨ run() ÉùÃ÷Ϊ synchronized £¬ÓÉÓÚÔÚÏ̵߳ÄÕû¸öÉúÃüÆÚÄÚËüÒ»Ö±ÔÚÔËÐУ¬Òò´Ë½«µ¼ÖÂËü¶Ô±¾ÀàÈκΠsynchronized ·½·¨µÄµ÷Óö¼ÓÀÔ¶²»»á³É¹¦¡£µ±È»ÎÒÃÇ¿ÉÒÔͨ¹ý½«·ÃÎÊÀà³ÉÔ±±äÁ¿µÄ´úÂë·Åµ½×¨Ãŵķ½·¨ÖУ¬½«ÆäÉùÃ÷Ϊ synchronized £¬²¢ÔÚÖ÷·½·¨Öе÷Óã¨ÈçÉÏÊöÀý×ÓÖеÄsale()·½·¨£¬ÔÚrun()·½·¨ÖÐÀ´µ÷ÓÃsale()·½·¨£©À´½â¾öÕâÒ»ÎÊÌ⣬µ«ÊÇ Java ΪÎÒÃÇÌṩÁ˸üºÃµÄ½â¾ö°ì·¨£¬ÄǾÍÊÇ synchronized ¿é¡£
2. synchronized ¿é£ºÍ¨¹ý synchronized¹Ø¼ü×ÖÀ´ÉùÃ÷synchronized ¿é¡£Óï·¨ÈçÏ£º
synchronized(syncObject) {
//ÔÊÐí·ÃÎÊ¿ØÖƵĴúÂë
}
¡¡¡¡synchronized ¿éÊÇÕâÑùÒ»¸ö´úÂë¿é£¬ÆäÖеĴúÂë±ØÐë»ñµÃ¶ÔÏó syncObject £¨ÈçÇ°ËùÊö£¬¿ÉÒÔÊÇÀàʵÀý»òÀ࣬ÉÏÊöÀý×ÓÖÐÎÒÃǶ¨ÒåÁËÒ»¸öStringÀàµÄ¶ÔÏ󣩵ÄËø·½ÄÜÖ´ÐУ¬¾ßÌå»úÖÆͬǰËùÊö¡£ÓÉÓÚ¿ÉÒÔÕë¶ÔÈÎÒâ´úÂë¿é£¬ÇÒ¿ÉÈÎÒâÖ¸¶¨ÉÏËøµÄ¶ÔÏ󣬹ÊÁé»îÐԽϸߡ£
¶Ôsynchronized(this)µÄһЩÀí½â
 Ò»¡¢µ±Á½¸ö²¢·¢Ï̷߳ÃÎÊͬһ¸ö¶ÔÏóobjectÖеÄÕâ¸ösynchronized(this)ͬ²½´úÂë¿éʱ£¬Ò»¸öʱ¼äÄÚÖ»ÄÜÓÐÒ»¸öÏ̵߳õ½Ö´ÐС£ÁíÒ»¸öÏ̱߳ØÐëµÈ´ýµ±Ç°Ïß³ÌÖ´ÐÐÍêÕâ¸ö´úÂë¿éÒÔºó²ÅÄÜÖ´ÐиôúÂë¿é¡£
¶þ¡¢È»¶ø£¬µ±Ò»¸öÏ̷߳ÃÎÊobjectµÄÒ»¸ösynchronized(this)ͬ²½´úÂë¿éʱ£¬ÁíÒ»¸öÏß³ÌÈÔÈ»¿ÉÒÔ·ÃÎʸÃobjectÖеķÇ


Ïà¹ØÎĵµ£º

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±íʾ½µÐòÅÅÁÐ ......

JavaÅàѵ,ÎÒΪʲôѡÔñ´«ÖDz¥¿Í

       ´ó¼ÒºÃ,ÎÒÊÇ´«ÖDz¥¿Í2009Äê12ÔÂ20ºÅ³å´Ì°àѧԱ.ÔÚ½ÓÏÂÀ´µÄ¼¸¸öÔÂÀïÎÒ½«ÕæʵµÄ¼Í¼ÔÚ´«ÖDz¥¿ÍµÄѧϰ¾­Àú.Ò»ÊǶÔ×Ô¼ºÑ§Ï°µÄ×ܽáºÍ¼Í¼;¶þÊÇÕæʵµÄ·´Ó¦ÔÚ´«ÖDz¥¿Íѧϰ¾­ÀúºÍ¹ý³Ì.
       ÏȽéÉÜÒ»ÏÂÎÒ×Ô¼º´Ó±ÏÒµµ½´«ÖDz¥¿Í֮ǰÔÚ±±¾©µÄ¾­Àú.09Äê±¾¿ ......

java×Ö·û´®×ª»»³ÉÈÕÆÚ

package com.gaosheng.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class StringToDate {

/**
* ×Ö·û´®×ª»»³ÉÈÕÆÚ
* @param stringdate Ҫת»»µÄ×Ö·û´®(×Ö·û´®¸ñʽ yyyy-MM-dd)
* @return
*/
public Date getStringtoDate(Strin ......

java»ù´¡ÎÊ´ð£¨2£©

11¡¢HashMapºÍHashtableµÄÇø±ð¡£
    HashMapÊÇHashtableµÄÇáÁ¿¼¶ÊµÏÖ£¨·ÇḬ̈߳²È«µÄʵÏÖ£©£¬ËûÃǶ¼Íê³ÉÁËMap½Ó¿Ú£¬Ö÷ÒªÇø±ðÔÚÓÚHashMapÔÊÐí¿Õ£¨null£©¼üÖµ£¨key£©,ÓÉÓÚ·ÇḬ̈߳²È«£¬Ð§ÂÊÉÏ¿ÉÄܸßÓÚHashtable¡£
HashMapÔÊÐí½«null×÷Ϊһ¸öentryµÄkey»òÕßvalue£¬¶øHashtable²»ÔÊÐí¡£
HashMap°ÑHashtableµÄ ......

java»ù´¡ÎÊ´ð£¨3£©

21¡¢Static Nested Class ºÍ Inner ClassµÄ²»Í¬¡£ Static Nested ClassÊDZ»ÉùÃ÷Ϊ¾²Ì¬£¨static£©µÄÄÚ²¿À࣬Ëü¿ÉÒÔ²»ÒÀÀµÓÚÍⲿÀàʵÀý±»ÊµÀý»¯¡£¶øͨ³£µÄÄÚ²¿ÀàÐèÒªÔÚÍⲿÀàʵÀý»¯ºó²ÅÄÜʵÀý»¯¡£
 22¡¢JSPÖж¯Ì¬INCLUDEÓ뾲̬INCLUDEµÄÇø±ð£¿¶¯Ì¬INCLUDEÓÃjsp:include¶¯×÷ʵÏÖ Ëü×ÜÊÇ»á¼ì²éËùº¬ÎļþÖеı仯£¬ÊʺÏÓÃÓÚ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ