Join suspend resum:
Package com;
Public class test ...{
Public static void main (string [] ARGs )...{
Firstthread first = new firstthread ();
Secondthread second = new secondthread ();
First. Start ();
Second. Start ();
Try ...{
System. Out. println ("waiting for first ...");
First. Join ();
System. Out. println ("it's a long wait ");
System. Out. println ("waking up second ...");
Second. Resume ();
System. Out. println ("waiting for second to running ");
Second. Join ();
} Catch (exception e )...{
}
System. Out. println ("this is the ending .");
}
}
Class firstthread extends thread ...{
Public void run ()...{
Try ...{
System. Out. println ("first thread running :");
Thread. Sleep (2000 );
System. Out. println ("first thread stop running :");
} Catch (interruptedexception e )...{
E. printstacktrace ();
}
}
}
Class secondthread extends thread ...{
Public void run ()...{
Try ...{
System. Out. println ("second thread running :");
System. Out. println ("second thread suspend itself :");
Suspend ();
System. Out. println ("second thread runs againg and finish :");
} Catch (exception e )...{
E. printstacktrace ();
}
}
}
Waiting for first...
First thread running:
Second thread running:
Second thread suspend itself:
First thread stop running:
It's a long wait
Waking up second...
Second thread runs againg and finish:
Waiting for second to running
This is the ending.