package classes.test;

/*
 * Verify that calling wait() does not cause other threads to wake up without
 * receiving notify().
 */
class WaitTest {

  static Object obj = new Object();

  static class Foo implements Runnable {
    Thread thread;

    Foo() {
      thread = new Thread(this);
      thread.start();
    }

    public void run() {
      synchronized(obj) {
        try {
          obj.wait();
        }
        catch (InterruptedException e) {
          System.out.println("Interrupted");
          return;
        }
        System.out.println("Not interrupted");
      }
    }
  }

  public static void main(String[] args) {
    Foo a = new Foo();
    Foo b = new Foo();
    try {
      Thread.currentThread().sleep(100);
    }
    catch (InterruptedException e) {}
    if (a.thread.isAlive()) a.thread.interrupt();
    if (b.thread.isAlive()) b.thread.interrupt();
  }

}

@@ -687,148 +687,122 @@
     
-try %7B%0A      Thread.currentThread().sleep(100);%0A    %7D%0A    catch (InterruptedException e
+if (a.thread.isAlive()) a.thread.interrupt();%0A    synchronized (obj
 ) %7B
-%7D
 %0A    
-if (a.thread.isAlive()) a.thread.interrupt();
+  Thread.currentThread().yield();%0A    %7D
 %0A   

make the WaitTest deterministic