OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.lang/] [Thread_Wait.java] - Blame information for rev 765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
// Test basic thread creation and wait/notify functionality.
2
 
3
public class Thread_Wait implements Runnable
4
{
5
  public static void main(String args[])
6
  {
7
    new Thread_Wait();
8
  }
9
 
10
  public Thread_Wait()
11
  {
12
    System.out.println("creating thread");
13
    Thread t = new Thread(this);
14
    t.start();
15
 
16
    try
17
    {
18
      Thread.sleep(100);
19
    }
20
    catch (Exception x)
21
    {
22
      System.out.println("exception occurred: " + x);
23
    }
24
 
25
    synchronized (this)
26
    {
27
      System.out.println("notifying other thread");
28
      notify();
29
    }
30
  }
31
 
32
  public void run()
33
  {
34
    System.out.println ("new thread running");
35
    synchronized (this)
36
    {
37
      try
38
      {
39
        wait();
40
      }
41
      catch (Exception x)
42
      {
43
        System.out.println("exception occurred: " + x);
44
      }
45
    }
46
    System.out.println ("thread notified okay");
47
  }
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.