title: How do I use wait/notifyAll
body: <p>I am wondering if it is possible in java to have a class that implements Runnable and if an object of the class goes to wait() (so thread stops running until it receives a signal), can another object of the same class notify it to continue running ?</p>
  
  <p>Ideally what i want to be able to do is:</p>
  
  <pre><code>public class ThreadClass implements Runnable{
  
   public void run(){
   //.. Does some arbitrary work
  
    if( aCondition){  //have it wait until something signals it to contine exection.
   this.wait();
   }
  
   //Continues to do more work.
  
   //finished whatever it needed to do. Signal all other threads of this object type to continue their work.
   this.notifyAll();
  
   }
  }
  </code></pre>
  
  <p>Is this possible and if so how would I go about doing it? I am trying to make it so that the object itself can manage itself and all other objects of the same type. So that no one using this class has to worry about managing it.</p>