求解:JSP的多线程同步
在看JSP中的多线程同步时看到以下实例
http://localhost:8080/Jsp/exercises/instanceconcurrenttest.jsp?username=a&password=123
http://localhost:8080/Jsp/exercises/instanceconcurrenttest.jsp?username=b&password=456
分别找开两个空白页,然后分别输入以上地址后回车。
显示的结果为:
第一个页面为空
第二个页面为空显示为:
http-8080-2
username=b
password=456
http-8080-1
username=b
password=456
书上的解释我看的不大明白。有没有朋愿意帮忙解释一下
1.>为什么第一个页面是空白的
2.>为什么第二个页面显示 打印了两次,除了线程的名字不样外,其它都一样
3.>关于类变量和实例变量 的区别在这里怎么体现
谢谢。
<%@ page contentType="text/html;charset=GBK" %><html><body><%! String username; String password; java.io.PrintWriter output;%><% username=request.getParameter("username"); password=request.getParameter("password"); output=response.getWriter(); showUserInfo();%><%! public void showUserInfo(){ int i=0; double sum=0.0; while(i++ <200000000){ sum+=i; } output.println(Thread.currentThread().getName()+"<br>"); output.println("username="+ username +"<br>"); output.println("password="+ password +"<br>"); } %>