Hello,
I looked through all the topics and couldn't find what I actually wanted.
What did I do?_
I created a thread for a ProcessBuilder which creates a new JVM to run a process.
Eg:
Thread thread = new Thread(threadGroup, threadName){
public void run(){
ProcessBuilder pb = new ProcessBuilder("java.exe", "-cp", "<path to the jar file>", "<main class in the JAR>", <arg1>, <arg2>);
pb.directory(<working-directory>);
.....
Process process = pb.start();
...
}
};
thread.start();
What I want?_
I have a JSP which displays the list of threads running in the application. And, the above thread is one of them. There's also a facility to stop the threads (actually it's interrupting). This works perfectly alright for all the threads except the above thread. When the STOP button is clicked to stop(i.e., to interrupt), the JSP shows the thread is interrupted but I could see the thread to go to completion even after. I even debugged the code and found that
thread.interrupt();+ is getting executed for the above thread but it's not really interrupting the thread.
What I think is happening?_
As the thread is creating a new process in the new JVM, the application that's running in the original JVM doesn't have control over that process.
Solution?_
If I'm thinking in the right direction, then is there a solution for this?
How can I get that thread to stop/interrupt?
Any help is really appreciated.
Thanks.