title: Java Thread Wait-Notify
body: <p>I have 3 threads (A, B, C) that i just can't make them work how i want them to.
  ALL these 3 threads share a reference to the same object - K.
  What i'm trying to do, is to start all 3 up, then at some point in time when thread A arrives in a certain state, pause threads B and C, until A executes some method work() and when work finishes, resume B and C.</p>
  
  <p>Now what i have in my code:
  Thread A has reference to both B and C.
  B and C have a method pause() { synchronized(K) { k.wait; }}
  When A arrives in that certain state, i call FROM A's run() method: B.pause(), C.pause().
  Now what i'm expecting is that Threads B and C will waiT until someone makes a: k.notifyAll(), BUT instead Thread A stops. Is this normal in java ?</p>
  
  <p>Code:</p>
  
  <pre><code>class A implements Runnable {
     private K k;
     private B b;
     private C c;
  
     void run() {
        while(something) {
           //do something
           b.pause();
           c.pause();
            // !!! here this thread will freeze and doSomething2 wont get executed.
            // what i want is to pause B, C, doSomething2 to get executed and then resume B and C
           //do something2 
           synchronized(k) {
             k.notifyAll();
           }
        }
     }
  }
  class B implements Runnable {
     private K k;
  
  
     void run() {
        while(something) {
           //dome something
           }
        }
     }
     public pause() {
         synchronized(k) { k.wait();}
     }
  }
  class C implements Runnable {
     private K k;
  
  
     void run() {
        while(something) {
           //dome something
           }
        }
     }
     public pause() {
         synchronized(k) { k.wait();}
     }
  }
  </code></pre>