class Demo
{
public static void main(String[] args){
text1 tx1 = new text1();
text2 tx2 = new text2();
Thread t1 = new Thread(tx1);
Thread t2 = new Thread(tx2);
t1.start();
t2.start();
}
}
class text1 extends Thread
{
public void run(){
for(int x=0;x<10;x++){
if(x==5)
try
{
wait();
}
catch (Exception e)
{
System.out.println("等待失败");
}
System.out.print(x);
}
}
}
class text2 extends Thread
{
public void run(){
for(int x=0;x<10;x++){
System.out.print("哈哈"+x);
}
}
}
运行的时候 说等待失败,怎么回事??
|