title: what is the point of rejoining the thread to the main-thread after the thread has been interrupted?
body: <p>I saw the code below from Java tutorial oracle. I was just wondering what is the point of rejoining the thread to the main thread after it has been interrupted? </p>
  
  <pre><code>if(((System.currentTimeMillis() - startTime) &gt; patience) &amp;&amp; t.isAlive()){
      threadMessage("tired of waiting");
      t.interrupt();
      t.join();
  
  }
  </code></pre>
  
  <p>I removed <code>t.join()</code> from the if statement and everything seem to be working exactly the same. So why was the code written the way it did? </p>
  
  <pre><code>public class SimpleThreads {
  
  
      static void threadMessage(String message){
          String threadName = Thread.currentThread().getName();
          System.out.format("%s: %s%n", threadName, message);
      }
  
      private static class MessageLoop implements Runnable {
  
          @Override 
          public void run (){
              String[] importantInfo = { "dog", "cat", "mice"};
  
              try {
                  for(int i = 0; i &lt; importantInfo.length; i++){
                      Thread.sleep(4000);
                      threadMessage(importantInfo[i]);
                  }
              } catch (InterruptedException e){
                  threadMessage("i wasn't done!");
              }
          }
      }
  
      public static void main(String[] args) throws InterruptedException {
          long patience = 10000;
  
          threadMessage("starting MessageLoop thread");
          long startTime = System.currentTimeMillis();
          Thread t = new Thread(new MessageLoop());
          t.start();
  
          threadMessage("waiting for MessageLoop thread to finish");
          while(t.isAlive()){
              threadMessage("still waiting...");
              t.join(1000);
  
              if(((System.currentTimeMillis() - startTime) &gt; patience) &amp;&amp; t.isAlive()){
                  threadMessage("tired of waiting");
                  t.interrupt();
                  t.join();
  
              }
          }
          threadMessage("finally");
      }
  
  
  }
  </code></pre>