public static
final Boolean lock = Boolean.TRUE;
public static
boolean runCond = true;
public static void main( String[] args ) {
Runnable runnable =
new Runnable() {
public void run() {
synchronized ( lock ) {
while
( runCond ) {
System.out.println(
"Hello World!" );
try
{ wait( 1000 ); } catch
(InterruptedException e) {}
}
}
}
};
Thread thread = new Thread(runnable);
thread.start();
try { Thread.sleep( 3000 ); } catch (InterruptedException e) {}
thread.suspend();
try { Thread.sleep( 3000 ); } catch (InterruptedException e) {}
thread.resume();
runCond = false;
}
|
|