source: trunk/gcc/libjava/testsuite/libjava.lang/Thread_Alive.java

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 985 bytes
Line 
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
5public 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}
Note: See TracBrowser for help on using the repository browser.