title: Run a class instance as a thread by itself
body: <p>I have this piece of code:</p>
  
  <pre><code>Timeout s = new Timeout();
  Timer timer = new Timer();
  timer.schedule(s, 1000L); // fires after 1 second
  </code></pre>
  
  <p>How can I launch the following piece of code as a thread by itself? Would I need to pass the timer and Timeout to a Runnable and then start it? What happens if the thread's Run() ends before the timer is fired?</p>
  
  <p>I am thinking of doing this instead:</p>
  
  <pre><code>ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
          Timeout s = new Timeout(); // Timeout is a runnable
          ses.schedule(s, 10, TimeUnit.SECONDS);
  </code></pre>
  
  <p>but how do I exit the thread after the timeout? I run out of thread after a while</p>
  
  <p>Thanks</p>