1 Reply Latest reply on Jan 25, 2007 1:47 PM by brado

    How to stop the SchedulerThread

    jrojas_pb

      I have been running a java based process that uses the ScheduLerThread to execute timers.

      new SchedulerThread().start()


      When the process completed, the SchedulerThread would continue running indefinitely, until I read a couple of posts and came up with this solution.

      I think it gets around an existing issue that prevents the SchedulerThread from being stopped by the outside application.

      CODE TO START THE SchedulerThread:
       StoppableSchedulerThread schedulerThread = new StoppableSchedulerThread();
       schedulerThread.start();
      


      CODE TO STOP THE SchedulerThread:
       // Stop the scheduler thread
       // the SchedulerThread will stop after a few seconds
       schedulerThread.stopRunning();
      


      CODE FOR StoppableSchedulerThread.java:
      package org.jbpm.scheduler.impl;
      
      public class StoppableSchedulerThread extends SchedulerThread
      {
       public void stopRunning()
       {
       super.keepRunning = false;
       }
      }
      





        • 1. Re: How to stop the SchedulerThread
          brado

          Just wanted to check ... have you had good success with this approach? My basic need is to create some external management of this Scheduler, i.e. be able to change the polling interval, and stop / restart the Scheduler.

          I was wondering if you have found the means below as effective to stop / start the Scheduler. I haven't gotten a chance to tear the source code apart, so I don't know if the SchedulerThread itself is acting as a dispatcher for starting other threads to handle tasks, but if so, I would be interested in how a stop on the SchedulerThread itself interacts with these child worker threads, and if all of them have to stop for the SchedulerThread to stop, or if the SchedulerThread stops immediately, but these workers keep running.

          Again, forgive me if I've just speculated on a scenario which doesn't exist, I just haven't been able to read the source code yet.

          Thanks,

          Brad