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] - Rev 765

Compare with Previous | Blame | View Log

// Test basic thread creation and wait/notify functionality.
 
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 occurred: " + 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 occurred: " + x);
      }
    }    
    System.out.println ("thread notified okay");
  }
}
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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