class NewThread implements Runnable ... { String name; Thread t; boolean suspendFlag; NewThread(String threadName)...{ name = threadName; t=new Thread(this,name); System.out.println("New Thread:" + name); suspendFlag=false; t.start(); } public void run()...{ try ...{ for(int i=15;i>0;i--)...{ System.out.println( name + ":" + i); Thread.sleep(200); synchronized(this)...{ while(suspendFlag)...{ wait(); } } } } catch (InterruptedException e) ...{ System.out.println( name + " thread interrupted."); e.printStackTrace(); } System.out.println( name + " exiting."); } public void mysuspend()...{ suspendFlag=true; } public void myresume()...{ suspendFlag=false; notify(); }} class PcSleep ... { public static void main(String[] args) ...{ NewThread obj1=new NewThread("ONE"); NewThread obj2=new NewThread("TWO"); try ...{ Thread.sleep(1000); obj1.mysuspend(); //obj1.t.suspend(); System.out.println( "Suspend thread one."); Thread.sleep(1000); obj1.myresume(); //obj1.t.resume(); System.out.println( "Resume thread one."); obj2.mysuspend(); //obj2.t.suspend(); System.out.println( "Suspend thread two."); Thread.sleep(1000); obj2.myresume(); //obj2.t.resume(); System.out.println( "Resume thread two."); } catch (InterruptedException e) ...{ System.out.println( "Main thread interrupted."); e.printStackTrace(); } try ...{ System.out.println( "Waiting thread finish."); obj1.t.join(); obj2.t.join(); } catch (InterruptedException e1) ...{ e1.printStackTrace(); } System.out.println( "Main thread exiting."); }}