I accidently started a thread from beanshell in infinite loop. Now it has
slowly started taking up more and more CPU and might soon go out of stack
Is there any way I can stop this particular thread without affecting the
rest of JVM?
I am prepared to take a risk of trying out any method that you could have.
View this message in context: http://www.nabble.com/Stopping-a-thread-from-beanshell-t1192089.html#a3142081
Sent from the BeanShell - Dev forum at Nabble.com.
--- Upendra <upendra.dashputre@...> wrote:
> I accidently started a thread from beanshell in
> infinite loop. Now it has
> slowly started taking up more and more CPU and might
> soon go out of stack
> Is there any way I can stop this particular thread
> without affecting the
> rest of JVM?
> I am prepared to take a risk of trying out any
> method that you could have.
> Please reply.
First off, bad idea to be playing around in a JVM
instance you are using for production and don't need
to stop. Next thing to do is call interrupt on the
thread if you have any sleep calls inside and aren't
catching the interrupted exceptions and ignoring them.
If you are not sleeping you can call stop granted you
aren't catching exceptions and not rethrowing them
(deprecated, but still around). Otherwise, you can
call suspend on the thread and just let it stay that
way until the JVM will be restarted at some management
point (as long as you don't have any monitors on
anything which you might cause deadlocks in other
threads). Non are great solutions, but might save you
a VM restart. Depending on what you are doing the
state of the JVM may be compromised, but if it's all
local instances to the thread and you are not locking
any static references then you should be fine.