]> gcc.gnu.org Git - gcc.git/blob - libjava/testsuite/libjava.lang/Thread_Alive.java
Thread_Wait.java: New file.
[gcc.git] / libjava / testsuite / libjava.lang / Thread_Alive.java
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>
4
5 public class Thread_Alive implements Runnable
6 {
7 public static void main(String args[]) throws InterruptedException
8 {
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());
14
15 Thread.sleep(100);
16
17 synchronized (ta)
18 {
19 ta.notifyAll();
20 }
21
22 t.join();
23 System.out.println(t.isAlive());
24
25 try
26 {
27 t.start();
28 System.out.println("Error: dead thread can be restarted.");
29 }
30 catch (IllegalThreadStateException x)
31 {
32 System.out.println ("ok");
33 }
34
35 System.out.println(t.getThreadGroup());
36 }
37
38 public synchronized void run()
39 {
40 try
41 {
42 wait();
43 }
44 catch (InterruptedException x) {}
45 }
46
47 }
This page took 0.037809 seconds and 5 git commands to generate.