mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-19 14:09:52 +08:00
e8904f655d
2000-03-23 Bryce McKinlay <bryce@albatross.co.nz> * libjava.lang/Thread_Wait.java: New file. * libjava.lang/Thread_Sleep.java: New file. * libjava.lang/Thread_Monitor.java: New file. * libjava.lang/Thread_Wait.out: New file. * libjava.lang/Thread_Sleep.out: New file. * libjava.lang/Thread_Monitor.out: New file. * libjava.lang/Thread_Interrupt.java: New file. * libjava.lang/Thread_Wait_2.java: New file. * libjava.lang/Thread_Wait_2.out: New file. * libjava.lang/Thread_Wait_Interrupt.java: New file. * libjava.lang/Thread_Wait_Interrupt.out: New file. * libjava.lang/Thread_Interrupt.out: New file. * libjava.lang/Thread_Join.java: New file. * libjava.lang/Thread_Join.out: New file. * libjava.lang/Thread_Alive.java: New file. * libjava.lang/Thread_Alive.out: New file. From-SVN: r32706
48 lines
985 B
Java
48 lines
985 B
Java
// Test the status of the isAlive() flag before, during, and after thread
|
|
// execution. Check that thread's threadgroup is null after thread exits.
|
|
// Origin: Bryce McKinlay <bryce@albatross.co.nz>
|
|
|
|
public class Thread_Alive implements Runnable
|
|
{
|
|
public static void main(String args[]) throws InterruptedException
|
|
{
|
|
Thread_Alive ta = new Thread_Alive();
|
|
Thread t = new Thread(ta);
|
|
System.out.println(t.isAlive());
|
|
t.start();
|
|
System.out.println(t.isAlive());
|
|
|
|
Thread.sleep(100);
|
|
|
|
synchronized (ta)
|
|
{
|
|
ta.notifyAll();
|
|
}
|
|
|
|
t.join();
|
|
System.out.println(t.isAlive());
|
|
|
|
try
|
|
{
|
|
t.start();
|
|
System.out.println("Error: dead thread can be restarted.");
|
|
}
|
|
catch (IllegalThreadStateException x)
|
|
{
|
|
System.out.println ("ok");
|
|
}
|
|
|
|
System.out.println(t.getThreadGroup());
|
|
}
|
|
|
|
public synchronized void run()
|
|
{
|
|
try
|
|
{
|
|
wait();
|
|
}
|
|
catch (InterruptedException x) {}
|
|
}
|
|
|
|
}
|