为什么这个程序中的睡眠状态不执行,应该打印出来是0514233241
package a;
class Test3 implements Runnable {
public void run()
{
for(int i =0;i<5;i++)
{ System.out.println( i );
try{ Thread.sleep(50);
}catch(InterruptedException e){
e.printStackTrace();
}}
}}
class Test2 implements Runnable{
public void run()
{for(int i=5;i>0;i--){
System.out.println( i);
try{ Thread.sleep(50);
}catch(InterruptedException e){
e.printStackTrace();
}}
}
}
public class Test1{
public static void main(String args[]){
Test3 lx =new Test3();
Test2 lx1 = new Test2();
Thread t1 = new Thread(lx);
Thread t2 = new Thread(lx1);
t1.run();
t2.run();}
}
------解决方案--------------------
线程启动:
t1.start();
t2.start();