await() { if (flag == true) System.out.println(Thread.currentThread().getName() + ": flag: already set"); else   { while (flag == false) { try { wait(1000000); } catch (InterruptedException e) {} if (flag == false) System.out.println(Thread.currentThread().getName() + ": flag: timed out"); } System.out.println(Thread.currentThread().getName() + ": flag: notification received"); }
synchronized void await() { Thread current = Thread.currentThread(); String name = current instanceof Task ? ((Task)current).getTaskName() : "Main "; if (flag == true) { System.out.println(name + ": flag: already set"); } else   { while (flag == false) { try { wait(1000000); } catch (InterruptedException e) {} if (flag == false) System.out.println(name + ": flag: timed out");
   await()      {      if (flag == true)         System.out.println(Thread.currentThread().getName() + ": flag: already set");      else   {         while (flag == false) {            try { wait(1000000); } catch (InterruptedException e) {}            if (flag == false)                   System.out.println(Thread.currentThread().getName() + ": flag: timed out");            }         System.out.println(Thread.currentThread().getName() + ": flag: notification received");         }      }