I think I know what your problem was. You cannot kill
threads with jdb
unless they are first suspended. But one of the strange things in JVM is that you cannot suspend a sleeping thread. If it's "running (at breakpoint)", which really also means suspended, then it can be killed:
main[1] threads
Group system:
(java.lang.ref.Reference$ReferenceHandler)0x162 Reference Handler cond. waiting
(java.lang.ref.Finalizer$FinalizerThread)0x161 Finalizer cond. waiting
(java.lang.Thread)0x160 Signal Dispatcher running
Group main:
(java.lang.Thread)0x1 main running (at breakpoint)
main[1] kill 0x1 new java.lang.Exception("die!")
killing thread: main
main[1] instance of java.lang.Thread(name='main', id=1) killed
OTOH, if you're trying to kill a thread that's sleeping, that seems impossible...
> threads
Group system:
(java.lang.ref.Reference$ReferenceHandler)0x162 Reference Handler cond. waiting
(java.lang.ref.Finalizer$FinalizerThread)0x161 Finalizer cond. waiting
(java.lang.Thread)0x160 Signal Dispatcher running
Group main:
(java.lang.Thread)0x1bf Thread-0 sleeping
(java.lang.Thread)0x1c1 DestroyJavaVM running
> kill 0x1bf new java.lang.Exception("die!")
killing thread: Thread-0
> com.sun.tools.example.debug.expr.ParseException: Unable to create java.lang.Exception instance
Expression must evaluate to an object
> suspend
All threads suspended.
> kill 0x1bf new java.lang.Exception("die!")
killing thread: Thread-0
> com.sun.tools.example.debug.expr.ParseException: Unable to create java.lang.Exception instance
Expression must evaluate to an object
> threads
Group system:
(java.lang.ref.Reference$ReferenceHandler)0x162 Reference Handler cond. waiting
(java.lang.ref.Finalizer$FinalizerThread)0x161 Finalizer cond. waiting
(java.lang.Thread)0x160 Signal Dispatcher running
Group main:
(java.lang.Thread)0x1bf Thread-0 sleeping
(java.lang.Thread)0x1c1 DestroyJavaVM running
>
Even switching to that (sleeping) thread's own stack frame doesn't exactly help
> thread 0x1bf
Thread-0[1] kill 0x1bf new java.lang.Exception("die!")
killing thread: Thread-0
Thread-0[1] Thread not suspended
Expression must evaluate to an object
Also note that JDWP specific threads cannot be killed that way at all (via JDI, which jdb
is also using underneath), as libjdwp
will err on the request. Given the thread name pool-766-thread-1
involved in your example, I don't think it was one of those (JDWP) threads though.