Simple tool to attach to a Java VM and kill an individual thread.
Switch branches/tags
Nothing to show
Clone or download
Failed to load latest commit information.
src/main/java/com/github/jglick/jkillthread Initial version. Nov 5, 2013 Noting jstack as well as jps. Oct 1, 2015
pom.xml Initial version. Nov 5, 2013

Command-line tool to kill a single thread in a Java VM, using the Oracle JDK 6+ Attach API.

Download jkillthread-1.0.jar and run using the java command from a JDK to get usage instructions. Essentially you pass a process ID (or unique name substring) and then a thread name (or substring):

java -jar jkillthread-1.0.jar 12345 "rogue HTTP handler"

(jps -lm is useful for finding a process ID. jstack 12345 can be used to see currently running threads.)

Beware that killing a thread in Java (Thread.stop) can have various effects, depending on what it was doing:

  • It might die quietly and that is that.
  • It might die, but print or log a stack trace somewhere first.
  • It might die but a similar thread be automatically relaunched by some sentinel.
  • It might not die because it is blocked in some native call which does not honor stop.
  • It might go into an odd state and not release locks that it should have. (Theoretically. I have never actually seen this happen.)

Caveat interfector!