title: Inter thread communication java
body: <p>I want to make threads in my application talk with each other. My scenario is mentioned below: (searched for this, but didn't find anything)</p>
  
  <p>For instance, 10 threads are doing something. Thread 1 encounters some condition on which it will safely terminate, but I also need it to tell all other threads to stop what they are doing and terminate safely.</p>
  
  <p>One way to do this is to share a variable and each thread checks this variable before doing something. The caveat is that I need to keep checking this variable at certain checkpoints.</p>
  
  <p>It would be better if there was some way for thread1 to just signal others to stop what they are doing and terminate safely.</p>
  
  <p>Any such package available or something else which does this without complicating things too much?</p>