Re: Aborting Interpretting
Alexey Zinger <inline_four-/[email protected]> Mon, 14 Feb 2005 11:10:39 -0800 (PST)
| Newsgroups | gmane.comp.java.beanshell.user,gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
--- Patrick Niemeyer <[email protected]> wrote: > > On Feb 14, 2005, at 10:33 AM, Alexey Zinger wrote: > > > I thought one could simply terminate the thread it's running in. I > > haven't > > tried it though, but see no reason why this shouldn't work. BSH > > doesn't keep > > any state persisted on the hard drive that could get corrupted or > > anything like > > that, right? > > Script execution control will definitely be near the top of the list > for new features. > > In the interum, if you just want a course grained "abort" button, > running the script in its own thread and using the deprecated Thread > stop() method will probably do exactly what you want. > > The reasons that Java's Thread stop() method was deprecated are more > involved with fine grained recovery of locks and resources. Normally > you can't just halt a thread in the middle of an activity and expect > synchronized code to come out in a consistent state. With that said, > since each BeanShell interpreter is almost entirely self contained > (there are just a few ways to share static data across them) it > probably won't affect you unless you are doing some elaborate > application level synchronization between interpreters or between Java > and the script interpreter. > > Here is Sun's FAQ on Thread deprecation: > > http://java.sun.com/j2se/1.4.2/docs/guide/misc/ > threadPrimitiveDeprecation.html > > So, in short - yes, using a Thread and stop() on your script is > probably a fine solution until we offer a better one (hopefully soon). > > If anyone disagrees and thinks that Thread stop() is just totally evil > please feel free to chime in. > > > Pat > > Pat, my knee jerk reaction to having to stop a thread is to use Thread.interrupt() method: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#interrupt() Seems to do the right thing and it's not deprecated. But I haven't tried it myself. It's been a while since I needed to halt a thread and I did use Thread.stop() back then as it wasn't deprecated. ===== Alexey Briggs & Stratton 1988 Kawasaki EX500 (CCS) http://bsheet.sourceforge.net __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click