2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / testsuite / libjava.lang / Thread_Wait.java
bloba6492821b4b3a1bad42419791debb6e2aadaf902
1 // Test basic thread creation and wait/notify functionality.
2 // Origin: Bryce McKinlay <bryce@albatross.co.nz>
4 public class Thread_Wait implements Runnable
6 public static void main(String args[])
8 new Thread_Wait();
11 public Thread_Wait()
13 System.out.println("creating thread");
14 Thread t = new Thread(this);
15 t.start();
17 try
19 Thread.sleep(100);
21 catch (Exception x)
23 System.out.println("exception occurred: " + x);
26 synchronized (this)
28 System.out.println("notifying other thread");
29 notify();
33 public void run()
35 System.out.println ("new thread running");
36 synchronized (this)
38 try
40 wait();
42 catch (Exception x)
44 System.out.println("exception occurred: " + x);
47 System.out.println ("thread notified okay");