main(String args[]) { System.out.println("TestNotification");
public static void main(String args[]) { System.out.println("TestNotification");  int     cnt     = 20; Mailbox mailbox = new Mailbox(cnt); Flag    flag    = new Flag(); Task    tasks[] = new Task[cnt];  for (int i = 0; i < cnt; ++i) tasks[i] = new Task(mailbox, flag, i);  TestNotification test = new TestNotification(tasks); test.run();   mailbox.await();   for (int i = 0; i < cnt; ++i) System.out.println("main: " + mailbox.messages[i] + " replied");
   main(String args[])      {      System.out.println("TestNotification");      int     cnt     = 20;      Mailbox mailbox = new Mailbox(cnt);      Flag    flag    = new Flag();      Task    tasks[] = new Task[cnt];            for (int i = 0; i < cnt; ++i)         tasks[i] = new Task(mailbox, flag);            TestNotification test = new TestNotification(tasks);      test.run();            // wait for mailbox to fill up      mailbox.await();            // display mail      for (int i = 0; i < cnt; ++i)         System.out.println("main: " + mailbox.messages[i] + " replied");      // pause to allow tasks to queue up on flag      System.out.println("main: sleeping");      try { Thread.currentThread().sleep(1000); } catch (InterruptedException e) {}      System.out.println("main: running");         // release tasks waiting on flag, letting them terminate      flag.set();            // wait for them to terminate      for (int i = 0; i < cnt; ++i)         {         System.out.println("main: joining " + tasks[i].getName());         try {             tasks[i].join();             }         catch (InterruptedException e)             {             }         }      System.out.println("main: bye");      }