title: How to execute a piece of code only after all threads are done
body: <p>I have a logging code which needs to be executed after all <code>Threads</code>s are executed. </p>
  
  <pre><code>Thread t1 = new MyThread();
  Thread t2 = new MyThread();
  t1.run();
  t2.run();
  
  doLogging();
  </code></pre>
  
  <p>Is there any way to execute <code>doLogging()</code> only after both threads are done with their processing. Now that <code>doLogging()</code> is called as soon as t1 and t2 are started.</p>