I have a program \'foo\' running different threads, fooT1, fooT2, .. fooTn.
Now if I want write another program \'bar\', which could kill the thread fooTr, is that p
You could do this even without a separate application. Write your own startup class, which performs a pass-through of parameters to the original startup class of the application. Your class's main method though would create a thread that periodically checks the list of all threads (e.g., Thread.getAllStackTraces
or Thread.enumerate
), finds the offending thread, and invokes stop()
on it. Although Thread.stop
is deprecated, it still works.
Another option is to run the application under a Java debugger, say, jdb
and then suspend/kill the required thread. You could also add parameters to the application's startup so that the JVM can be attached to, then attach jdb
to the running JVM and suspect/kill the thread.