FSF GCC merge 02/23/03
[official-gcc.git] / libjava / testsuite / libjava.lang / Thread_Alive.java
blobd97ea25c5d3c95b7e00ab461bc58cf6e96ca3fec
1 // Test the status of the isAlive() flag before, during, and after thread
2 // execution. Check that thread's threadgroup is null after thread exits.
3 // Origin: Bryce McKinlay <bryce@albatross.co.nz>
5 public class Thread_Alive implements Runnable
7 public static void main(String args[]) throws InterruptedException
9 Thread_Alive ta = new Thread_Alive();
10 Thread t = new Thread(ta);
11 System.out.println(t.isAlive());
12 t.start();
13 System.out.println(t.isAlive());
15 Thread.sleep(100);
17 synchronized (ta)
19 ta.notifyAll();
22 t.join();
23 System.out.println(t.isAlive());
25 try
27 t.start();
28 System.out.println("Error: dead thread can be restarted.");
30 catch (IllegalThreadStateException x)
32 System.out.println ("ok");
35 System.out.println(t.getThreadGroup());
38 public synchronized void run()
40 try
42 wait();
44 catch (InterruptedException x) {}