title: How can a Thread that is asleep receive events?
body: <p>My code:</p>
  
  <pre><code>public class EventHandler implements Runnable, SomeEventListener {
      private static final EventHandler INSTANCE = new EventHandler();
      private static final Thread THREAD = new Thread(INSTANCE);
      private static volatile boolean isRunning = false;
  
      private EventHandler () {}
  
      private static EventHandler getInstance() {
          return INSTANCE;
      }
  
      public void start() {
          isRunning = true;
          THREAD.start();
      }
  
      public void stop() {
          isRunning = false;
      }
  
      //Listener method that was overriden
      public void onEvent(Event event) {
          //...do stuff
      }
  
  
      @Override
      public void run() {
          //Do nothing, let the listener do its job
          while (isRunning) {
              try {
                  logger.info("Sleeping...");
                  Thread.sleep(5000);
                  logger.info("Done sleeping...");
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
      } 
  }
  </code></pre>
  
  <p>}
  Basically the <code>run()</code> method does nothing - just sleeps every 5 seconds, wakes up, sleeps again. What I don't understand is when it's asleep, this <code>EventHandler</code> class still gets events. How does this happen? Shouldn't the class stop receiving events since the thread is asleep?</p>