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 ҲûÓÃѽ
Ê®·ÖÀ§»ó,Çë´ó¼Ò°ïÃ
Ïà¹ØÎÊ´ð£º
ÎÒJSPµÄÒ³ÃæÊÇ£º
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 52 in the jsp file: /vip_info.jsp
ÕË cannot be resolved
49: <table border="1& ......
ÓÐËÓÃjava×ö¹ý´òÓ¡·¢Æ±µÄ³ÌÐò£¬¸Ð¾õÕâ·½Ãæ²»ÊǺܺÿØÖÆ£¬Ï£Íû¸øµã½¨Ò飬×îºÃÄܸø³ö´úÂë
¼òµ¥µã¾Íµ÷ÓÃwindow.print()
ÄãÒ²¿ÉÒÔ°ÑÏÂÃæ´úÂë·Åµ½ÄãJSPÖÐ:
<html>
<head>
<title> ......
ÇëÎʸ÷λ¸ç¸ç½ã½ã£¬ÈçºÎÔËÓÃÏֳɵÄÄ£°åÀ´ÖÆ×÷ƯÁÁµÄJSPÍøҳѽ,»ØÕßÓзÖ!
×Ô¼º¶¥Ï£¬×ÜÓиßÊÖ°É,ÆÚ´ýÖÐ......
Èç¹ûÖ±½ÓÒýÓýøÈ¥
¿ÉÒÔÖ±½ÓÓÃjspµÄÖ¸ÁҲ¿ÉÒÔÓÃfreemarkÒýÓ㬼ǵøø·Ö
лл¸÷λÁË£¬¿´À´Î ......
ÎÒдÁ˸öjspÒ³Ã棬Ȼºó¸Ä¶¯ÁËһϣ¬¸Ä¶¯µÄÄÚÈݾÍÊÇÔÚjspÒ³ÃæµÄjsº¯ÊýÀï¼ÓÁ˸öalert()Óï¾ä£¬µ«ÊÇÎÒ·ÃÎÊÕâ¸öÒ³Ãæʱ£¬ËÀ»î¶¼ÊÇÔÀ´Ò³ÃæµÄÄÚÈÝ£¬ÎÒ¼ÓÁ˺ܶàalertº¯Êý»¹ÊÇû¸Ä¶¯Ç°µÄÒ³ÃæÄÚÈÝ£»tomcatÖØÆôÁË£¬Ò²ÖØв¿ÊðÕâ ......