How to kill a java thread using VisualVM or using a unix command?

java, multithreading

Solution

There is no safe way to "kill" a thread without killing the process it is in. It not something you would do deliberately. For testing purposes I would add code to your application to support this.

Problem

I m using windows 7 OS. I have around `6` threads in my application. For the purpose of testing the alerts to check the health of the threads, i need to kill the threads manually and check if the alerts are working properly. Can we kill a thread like how we kill a process with its `pid`?

Original source