public class MethodTest {
public static void main(String[] args){
FirstThread first=new FirstThread();
SecondThread second=new SecondThread();
first.start();
second.start();
try{
System.out.println("Waiting for firstThread finish...");
first.join();
System.out.println("It's a long time.");
System.out.println("Waking up the secondThread...");
second.resume();
System.out.println("Waiting for secondThread finish...");
second.join();
}catch(InterruptedException e){
}
System.out.println("I'm ready to finish too...");
}
}class FirstThread extends Thread{
public void run(){
try{
System.out.println("FirstThread startes running...");
Thread.sleep(1000);
System.out.println("FirstThread finishes running...");
}catch(InterruptedException e){
}
}
}class SecondThread extends Thread{
public void run(){
try{
System.out.println("SecondThread startes running...");
Thread.sleep(1000);
System.out.println("SecondThread finishes running...");
}catch(InterruptedException e){
}
}
}高手,请问有没可能最先打印secondThread starts running...

解决方案 »

  1.   

    除了Interrupted掉,不可能。
    second.resume();//多余
      

  2.   

    除了Interrupted掉,不可能。
    second.resume();//多余
      

  3.   

    我的SecondThread写错了,应该是:class  SecondThread  extends  Thread{  
        public  void  run(){  
            try{  
                System.out.println("SecondThread  startes  running...");  
                System.out.println("SecondThread  suspend itself...");
                suspend();
                System.out.println("SecondThread  startes again and finish running...");
            }catch(InterruptedException  e){  
            }  
        }  
    }