Can you wake up a waiting thread with something other than notifyXXX?

Prev      Next

Answer: Sure - try this

You will need to link to these:   

   // Determine whether there are other ways to wake up threads
   public class Q64 {
      public static void main (String arg[]) {
         M1 m1 = new M1 (false);  // Use notifyAll()
         M1 m2 = new M1 (false);  // Use notifyAll()
         W1 w1 = new W1 (1, m1);
         W1 w2 = new W1 (2, m2);
         W1 w3 = new W1 (3, m1);

         try { Thread.sleep(1000); } catch (Exception e) {}

         w1.interrupt();  // One way to get a waiting thread to go