title: restart a thread after exception is caught
body: <p>I am reading a UDP feed and I want the thread to attempt to restart if their is a failure. I think I have written my class correctly but would like someone to look over and see if there is something missing or I have written something that won't get the job done. In my catch clause I attempt to restart the thread every 6 seconds for 10 attempts. Is this a good solution, will it work? </p>
  
  <pre><code>class UDPReader extends Thread
  {
      private Thread t;
      private final String ip, socket, queue, threadName;
      private String ErrorMessage;
      private final JTextArea screen;
  
      UDPReader(String ip, String socket, String queue, String threadName, JTextArea screen) {
          this.ip = ip;
          this.socket = socket;
          this.queue = queue;
          this.threadName = threadName;
          this.screen = screen;
      }
  
      public void run()
      {
          try {
              byte[] i = null;
              ipaddrConnection ipaddr = new ipaddrConnection(ip, socket);
              parseUDP p = new parseUDP();
  
              screen.append("Thread " + threadName + " running\n");
              while(true)
              {
                  i = ipaddr.getPacket();
                  p.parseUDP(i); 
                  //Thread.sleep(0);
              }
          } 
          catch (IOException ex) {
              Logger.getLogger(MarketDataReader.class.getName()).log(Level.SEVERE, null, ex);
              ErrorMessage = "Thread " + threadName + " has failed, Attempting to Restart";
              screen.append("Thread " + threadName + " has failed, Attempting to Restart\n");
              Email email = new Email(ErrorMessage,"WARNING Market Data Reader Failure");
  
              for(int i = 0; i &lt; 10 &amp;&amp; t.isAlive() == false; i++)
              {
                  try {
                      start();
                      Thread.sleep(6000);
                  } catch (InterruptedException ex1) {
                      Logger.getLogger(UDPReader.class.getName()).log(Level.SEVERE, null, ex1);
                      ErrorMessage = "Thread " + threadName + " has failed, Contact System Administraitor";
                      screen.append("Thread " + threadName + " has failed, Contact System Administraitor\n");
                      email = new Email(ErrorMessage,"WARNING Market Data Reader Failure");
                  }
              }
          }
      }
  
      public void start() 
      {
          if (t == null)
        {
           t = new Thread (this, threadName);
           t.start ();
        }
      }
  }
  </code></pre>