I do have an application which starts a Calculation when User prompt START action. Whenever START action is received a new Thread A is executed. (1a and 1b in the diagram)
This Thread One is created and started at the application startup as below.
public static void main(String[] args) {
ScheduledExecutorService ses = Executors.newScheduledThreadPool(100);
ses.schedule(new ThreadOne(refObject), 3, TimeUnit.SECONDS);
ses.schedule(new ThreadTwo(refObject), 6, TimeUnit.SECONDS);
ses.schedule(new ThreadThree(refObject), 9, TimeUnit.SECONDS);
ses.shutdown();
}
This Thread One recursively checks a db level flag like 'isStartReqReceived' and once this flag is true, Thread One will execute it's logic.
Now I want to stop this thread, when User prompt STOP action. Is this possible ? What I really want is to stop Thread One.
Please note that my application is a java application which does not use any framework.