给你个线成的例子(可以正常运行),你看看吧
public class SimpleThread extends Thread{
static int tn = 0;
int count = 5;
int tnumber = ++tn;
SimpleThread(){
System.out.println("making " + tnumber);
}
public void run(){
while(true)
{
System.out.println("Thread" + tnumber + "(" + count+ ")");
if (--count == 0) return;
}
}
public static void main(String[] args){
for (int i = 0;i<5;i++){
new SimpleThread().start();
}
System.out.println("main");
}
}
public class SimpleThread extends Thread{
static int tn = 0;
int count = 5;
int tnumber = ++tn;
SimpleThread(){
System.out.println("making " + tnumber);
}
public void run(){
while(true)
{
System.out.println("Thread" + tnumber + "(" + count+ ")");
if (--count == 0) return;
}
}
public static void main(String[] args){
for (int i = 0;i<5;i++){
new SimpleThread().start();
}
System.out.println("main");
}
}
解决方案 »
- C3P0+hibernate出现错误!求解释
- 跨域登陆的问题
- 推荐个空间
- 请问一个关于java.lang.IllegalArgumentException: id to load is required for loading的问题!
- 怎么样使用logic:iterate进行集合输入?
- 一个ejb发布的错误!大家帮我看看
- tomcat的session和UTF-8问题
- windows下正常连接服务器,linux下就不行,高手求救!!!!
- 如何将resultset转换成xml
- 一个问题,别人是这样解答的,各位高手看看对不对如果不对的话,我应该怎么反驳?
- RMI服务器是怎么管理rmi请求的?
- norwaywoods能不能给一个xsl的例子给我啊?
A.member=0;
或者在申明时初始化之——
class A
{
static int member=0;
}