title: Observer pattern with threads
body: <p>I want to run several threads and join them at the end of my main method, so I can know when they have finished and process some info.</p>
  
  <p>I don't want to put my threads in an array and do a join() one by one as join is a blocking method and I stay would waiting in the main thread for some threads still running, while other threads may have already finished, without having a possibility of knowing.</p>
  
  <p>I have thought on the possibility of implementing an observer pattern for my threads: An interface with a update() method, an abstract class extending from thread (or implementing runnable) with set and get methods for the listeners and a class starting all my threads and waiting them to finish.</p>
  
  <p>If my understanding is right, an observer would not block in a specific join() for a thread. Instead it will wait somehow until an update() method is called by a thread to perform an action. In this case, the update() should be called right after the thread finishes.</p>
  
  <p>I'm clueless on how to implement this. I've tried with similar models, but I don't know how to use the observer/listener to wake/block my main thread. I've used this old post as a template: <a href="https://stackoverflow.com/questions/702415/how-to-know-if-other-threads-have-finished">How to know if other threads have finished?</a> but I can't find a way to wake my main method once a thread calls the update() method. There will be only one observer object instantiated for all threads.</p>
  
  <p>Could you think of a way to use an observer pattern to wait for all threads to finish without blocking main with one by one join() calls? Any other suggestion to solve this problem would be greatly appreciated. Thanks in advance.</p>