title: How to know when a thread has completed its task
body: <p>As I am using gui and I need to create a thread to complete a task. See I want to display a dialog letting the user know the task has been completed I have tried</p>
  
  <pre><code>if(!thread.isAlive()) {
      JOptionPane.showMessageDialog(null, "Done");
  }
  </code></pre>
  
  <p>But that doesnt work.</p>
  
  <p>Can anyone help me </p>
  
  <p>Thanks</p>