title: Why not to start a thread in the constructor? How to terminate?
body: <p>I am learning how to use threads in Java. And I wrote a class that implements Runnable to run concurrently to another thread. The main thread handles listening to the serial port where as the second thread will handle sending data to that same port.</p>
  
  <pre><code>public class MyNewThread implements Runnable {
      Thread t;
  
      MyNewThread() {
          t = new Thread (this, "Data Thread");
          t.start();
      }
  
      public void run()  {
          // New Thread code here 
      }
  </code></pre>
  
  <p>There first thread starts the second like this:</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) throws Exception{
          new MyNewThread();
          // First thread code there
      }  
  }
  </code></pre>
  
  <p>This works but my complier flags a warning saying: It is dangerous to start a new thread in the constructor.  Why is this?</p>
  
  <p>The second part to this question is: how if I have a loop running in one thread (the serial port listen thread) and I type an exit command in my second thread. How do I get the first thread to terminate?  Thanks.</p>