java Ïß³ÌÎÊÌâ - Java / Java SE
½ñÌì×öÁ˸öÏ̵߳ÄСÁÐ×Ó,´úÂëÈçÏÂ
public class Test
{
private int x;
public void foo()
{
int current=x;
x=current+1;
}
public void go()
{
for(int i=0;i<3;i++)
{
new Thread(){
public void run(){
foo();
System.out.println(x);
}
}.start();
}
}
public static void main(String[] str)
{
new Test().go();
}
}
ÓÐʱ»áÊä³ö
2 3 2
ÎҸоõºÜÆæ¹Ö,Ïë²»Ã÷°×ÆäÖеĵÀÀí,°´ÎÒ×Ô¼ºµÄ·ÖÎö,Ó¦¸ÃÊÇÕâÑùµÄ...
µ÷ÓÃgo()·½·¨ºó»áÆô¶¯Èý¸öÏß³Ì,Èý¸öÏ̶߳¼»áµ÷ÓÃfoo()Õâ¸ö·½·¨,foo()Õâ¸ö·½·¨Ö÷Òª¾ÍÊǸıä³ÉÔ±±äÁ¿xµÄÖµ,È»ºó´òÓ¡³öxµÄÖµ,ÏÔÈ»,ÕâÈý¸öÏß³ÌÊÇÒì²½µÄ,µ«ÊÇËüÃÇ·ÃÎʵÄx¶¼ÊÇͬһ¸ö³ÉÔ±±äÁ¿Ñ½,¶ÔÓÚ2£¬3£¬2ÕâÑùµÄÊä³ö,°´ÎҵķÖÎöÓ¦¸ÃÊÇÕâÑùµÄ,Ê×ÏÈÔËÐеÄÏß³Ìʹx¼Ó1ºó¾Í×èÈûÁË,È»ºóµÚ¶þ¸öÏß³ÌÔËÐÐʱ¿´µ½xÒѾµÈÓÚ1Á˾ÍÔÙ¼ÓÒ»µÈÓÚ2,È»ºóÆäÖÐÒ»¸ö×èÈû,ÁíÒ»¸ö´òÓ¡,ÒòΪ´òÓ¡µÄ¶¼ÊÇͬһ¸ö³ÉÔ±±äÁ¿ËùÒÔÓ¦¸ÃÊÇÐ޸ĺóµÄÖµ2ûʲôÎÊÌâ,È»ºóµÚÈý¸öÏß³ÌÓָıäxµÄÖµ²¢´òÓ¡³ö3(µÚÈý¸öÏß³ÌÖ´ÐÐÊ±Ç°Ãæ×èÈûµÄÄǸöÏß³ÌÓ¦¸Ã»¹ÔÚ×èÈû²»È»Ôõô»á´òÓ¡3),È»ºó×èÈûµÄÄǸöÏß³ÌÔËÐÐ,°´Àí˵ÕâʱËüÒª´òÓ¡µÄxÒѾ±»µÚÈý¸öÏß³ÌÐÞ¸ÄÁ˳É3ÁË,Ϊʲô»¹Êä³ö2.ÎÒÒ²¿¼Âǵ½ÁË¿ÉÄÜ·ÃÎʵÄÊDz»Í¬ÄÚ´æÇøµÄ±äÁ¿Öµ,µ«ÔÚxǰ¼ÓÉÏÁË volatile ҲûÓÃѽ
Ê®·ÖÀ§»ó,Çë´ó¼Ò°ïÃ
Ïà¹ØÎÊ´ð£º
ΪʲôHTMLÒÔ¼°Ò»Ð©ÆäËü±êÇ©»áÏÔÊ¾Ò»Ð©ÌØ¶¨±íÏÖÐÎÊ½ÄØ£¿ÈçHTMLÖеĻ»ÐбêÇ©<BR/>ÔڵײãÊÇÔõÑùʵÏÖµÄÄØ£¿ÏÖʵµÄÔÀíÊÇÊ²Ã´ÄØ
È¥W3C¹Ù·½ÍøÕ¾ÉÏ£¬¿´¿´°É£¡ÎÒÏëÒ»¿´Äã¾ÍÃ÷°×ÁË
ÎҲºͱàÒëÔÀíÓйأ¬ä¯ÀÀÆ÷Àï¿É ......
insert into [ScholarshipManagement].[dbo].[department] ([department],[specialization] ,[grade]) output inserted.departmentID values(? ,? ,? )
ÇëÎÊ´ó¸çÃÇÕâ¸ösql Óï¾äÓ¦¸ÃÓÃJavaÀïµÄÄǸöÊý¾Ý¿â²Ù×÷·½·¨£¿ ......
¾ÍÊǼòµ¥µÄ´«ÖµºÍȡֵ
ÇëÎÊÂ¥Ö÷ÏëÎÊʲô£¿
jspÒ³Ãæ²ÉÓÃ±íµ¥»òÕßjavabean´«Öµ¶¼¿ÉÒÔ£¬Ê¹ÓÃrequest.getParameter()»ñµÃʹÓÃ±íµ¥´«¹ýÀ´µÄÖµ¡£
ÎÊÎÊÌ⣬ÏȰÑÎÊÌâ˵Çå³þµã£¡£¡ ÎÊÌâ̫ģºý£¡£¡
ÎÊÎÊÌ⣬ÏȰÑÎ ......
ÔõôÑù½«id´«¹ýÈ¥°¡£¿£¿£¿ÊǼòµ¥µÄ´«¡£¡£¡£ÔÚµØÖ·À¸ÖÐдidºÅ
LZ ºÃÓÄĬ£¡²»ÖªµÀÄãµÄÒâ˼£¿
ÊÇÏë°ÑID ´«µ½ACTION ? ͨ¹ýURl id=?
²»¹»Ïêϸ ±ðÈ˲»ÖªµÀÔõÑù°ïÄã
../XXXXX.do?id=XXXX&id2=XXXXX
......