I have code like this. Each method is a stage exposed to rest call independently:
void methodA(@FormDataParam ("fd") fd){
//Executor spawns thread - takes around 15-30 min as per data
//main thread exits with "Process begun" message while thread spawned still running
}
void methodB(){
//Executor spawns thread - takes around 60-600 min as per data
//main thread exits with "Process begun" message while thread spawned still running
}
void methodC(){
//Executor spawns thread - takes around 10-60 min as per data
//main thread exits with "Process begun" message while thread spawned still running
}
These stages were executed sequentially earlier. Now, additional requirement is to execute them in one go if required. For that one single api has to be exposed as rest api like:
void methodAll(@FormDataParam ("fd") fd){
methodA(fd);
methodB();
methodC();
}
Problem is methodA(), methodB(), methodC() main thread return immediately while threads spawned by them are still running and hence result in start of execution of other subsequent methods before prior one completes.
I am in fix, how to solve this problem without substantial changes to existing three api?