title: Threads; Creating a separate thread to periodically do something
body: <p>As an addition to my current application, I need to create a separate thread which will periodically do some processing</p>
  
  <p>I've create a new class to do all this, and this class will be loaded on startup of my application.</p>
  
  <p>This is what I have so far :</p>
  
  <pre><code>public class PeriodicChecker extends Thread
  {
      static
      {
          Thread t = new Thread(new PeriodicChecker());
          while(true)
          {
              t.run();
              try
              {
                  Thread.sleep(5000l);
              }
              catch (InterruptedException e)
              {
                  e.printStackTrace();
              }
          }
      }
  
      /**
       * Private constructor to prevent instantiation
       */
      private PeriodicChecker()
      {
  
      }
  
      @Override
      public void run()
      {
          System.out.println("Thread is doing something");
          // Actual business logic here, that is repeated
      }
  
  }
  </code></pre>
  
  <p>I want to make constructor private to prevent other people from attempting to instantiate this class accidentally. How can I achieve this?</p>
  
  <p>Also, is there anything bad about my implementation of such requirements? I'm only creating one thread which will run then sleep, have I missed anything obvious? I haven't worked with threads before</p>