mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-19 20:39:43 +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
50 lines
901 B
Java
50 lines
901 B
Java
// Test basic thread creation and wait/notify functionality.
|
|
// Origin: Bryce McKinlay <bryce@albatross.co.nz>
|
|
|
|
public class Thread_Wait implements Runnable
|
|
{
|
|
public static void main(String args[])
|
|
{
|
|
new Thread_Wait();
|
|
}
|
|
|
|
public Thread_Wait()
|
|
{
|
|
System.out.println("creating thread");
|
|
Thread t = new Thread(this);
|
|
t.start();
|
|
|
|
try
|
|
{
|
|
Thread.sleep(100);
|
|
}
|
|
catch (Exception x)
|
|
{
|
|
System.out.println("exception occured: " + x);
|
|
}
|
|
|
|
synchronized (this)
|
|
{
|
|
System.out.println("notifying other thread");
|
|
notify();
|
|
}
|
|
}
|
|
|
|
public void run()
|
|
{
|
|
System.out.println ("new thread running");
|
|
synchronized (this)
|
|
{
|
|
try
|
|
{
|
|
wait();
|
|
}
|
|
catch (Exception x)
|
|
{
|
|
System.out.println("exception occured: " + x);
|
|
}
|
|
}
|
|
System.out.println ("thread notified okay");
|
|
}
|
|
}
|