class MyThread implements Runnable
{
private int num = 0 ;
public void run(){
for(int i = 0;i<10;i++){
try{
Thread.sleep(20) ;
}catch(Exception e){}
System.out.println(num++) ;
}
}
}
public class RunnableDemo
{
public static void main(String[] args){
MyThread mt = new MyThread() ;
Thread t1 = new Thread(mt) ;
Thread t2 = new Thread(mt) ;
Thread t3 = new Thread(mt) ;
Thread t4 = new Thread(mt) ;
t1.start() ;
t2.start() ;
t3.start() ;
t4.start() ;
}
}
为什么运行结果不是1到39,求指点。。。。 |