public class TestThread { public static void main(String[] args) {
MYFirstThread first = new MYFirstThread() ;//这里有错
SecondThread second = new SecondThread();;//这里有错
first.start();
second.start();
try{
System.out.println("Waiting for first thread finished..");
first.join();
System.out.println("It is a long wait!!");
System.out.println("Waking up Second thread!");
second.resume();
System.out.println("Waiting for Second Thread finished..");
second.join();

}catch (InterruptedException e) {
// TODO: handle exception
}
System.out.println("I am finished too");
} class MYFirstThread extends Thread {
public void run() {
        try{
         System.out.println("First Thread Start!");
         sleep(1000);
         System.out.println("First Thread Stoped!");
        }catch (InterruptedException e){
        
        }

}
}
class SecondThread extends Thread{

解决方案 »

  1.   

    public class TestThread { public static void main(String[] args) {
    MYFirstThread first = new MYFirstThread() ;
    SecondThread second = new SecondThread();
    first.start();
    second.start();
    try{
    System.out.println("Waiting for first thread finished..");
    first.join();
    System.out.println("It is a long wait!!");
    System.out.println("Waking up Second thread!");
    second.resume();
    System.out.println("Waiting for Second Thread finished..");
    second.join();

    }catch (InterruptedException e) {
    // TODO: handle exception
    }
    System.out.println("I am finished too");
    } class MYFirstThread extends Thread {
    public void run() {
            try{
             System.out.println("First Thread Start!");
             sleep(1000);
             System.out.println("First Thread Stoped!");
            }catch (InterruptedException e){
            
            }

    }
    }
    class SecondThread extends Thread{
    public void run(){
    System.out.println("Second thread Start Running!");
    System.out.println("Second Thread Suspend self!");
    suspend();
    System.out.println("Second Thread Run again");
    }
    }
    }
      

  2.   

    static的方法不能访问自己类里的东西的,你把那两个class定义到外面去,不要用inner class
      

  3.   

    帮你修改了一下.
    还有你的程序里面resume();和suspend();方法,是已经被淘汰的方法.不要用他们了!
    public class TestThread { public static void main(String[] args) {
    TestThread tt = new TestThread();
    MYFirstThread first = tt.new MYFirstThread();
    SecondThread second = tt.new SecondThread();
    first.start();
    second.start();
    try{
    System.out.println("Waiting for first thread finished..");
    first.join();
    System.out.println("It is a long wait!!");
    System.out.println("Waking up Second thread!");
    //second.checkAccess();
    System.out.println("Waiting for Second Thread finished..");
    second.join();

    }catch (InterruptedException e) {
    // TODO: handle exception
    }
    System.out.println("I am finished too");
    } class MYFirstThread extends Thread {
    public void run() {
            try{
             System.out.println("First Thread Start!");
             sleep(1000);
             System.out.println("First Thread Stoped!");
            }catch (InterruptedException e){
            
            }

    }
    }
    class SecondThread extends Thread{
    public void run(){
    System.out.println("Second thread Start Running!");
    System.out.println("Second Thread Suspend self!");
    //checkAccess();
    System.out.println("Second Thread Run again");
    }
    }
    }
      

  4.   

    to  interhanchi 为什么要用TestThread tt = new TestThread()?
    不写这句代码编译的时候为什么会出现
    TestThread.java uses or overrides a deprecated API 

    Recompile with -deprecation for details
    先谢谢了!