title: Start & Stop a ScheduledExecutorService in Java EE environment using servlet
body: <p>We have a requirement where in we need to monitor remote JVM details via JMX using a simple servlet application. So things done till now in a standalone application is</p>
  
  <p>1) Creat a JMX connector &amp; get the Memory data --> done
  2) We need to constantly monitor &amp; get the records 
  (2.1 > which can be considered as scheduled task at constant delay &amp; insert the records into DB Or 2.2> does the JMX gives the history if yes which MBean to access for the info?).</p>
  
  <p>Here I am planning to use an interface to register the domain , followed to it. Have start &amp; stop button from JSP. The functionality been when we click start the system will run the scheduler (ScheduledExecutorService  ) &amp; capture the records at background to give the history. When the uses clicks stop the scheduler has to stop the background process.  The question is how can we control &amp; get the object of a scheduler ? </p>
  
  <p>1) In other words how can we start &amp; stop a ScheduledExecutorService via servlets ? start a thread from one servlet &amp; stop a thread from another servlet  for a particular task ? </p>
  
  <p>2) What if we have a clustered/load balanced environment ?</p>
  
  <p>Currently am thinking of adding each ScheduledExecutorService  into HashMap , key been the task object &amp; value been the ScheduledExecutorService  using SingleTon desgin pattern. Is there any default approach. The loop whole with SingleTon is in clustered/load balanced environment we may not be able to get the appropriate update objects.</p>
  
  <p>Looking forward for your valuable suggestion.</p>