title: How to implement event listener in background of the main program in java?
body: <p>Hi im a beginner so sorry for my question if it sounds naive.</p>
  
  <p>I want to implement a thread that runs in the background and listens all the time. By listening i mean, say it keeps check on a value returned from main thread and if the vaue exceeds certain figure, it executes some method, or say exits the program.  </p>
  
  <p>If you could give me some idea or at least refer me to something useful, that'll be great.</p>