Re: Stopping a thread from beanshell
Wade Chandler <hwadechandler-beanshell-/[email protected]> Wed, 15 Mar 2006 06:20:17 -0800 (PST)
| Newsgroups | gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
--- Upendra <[email protected]> wrote: > > Hi, > 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 > space. > 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. Wade ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642