On May 29, 11:10 am, Wernke <[email protected]> wrote: > Hi all, > > is there an elegant way to interrupt and abort the execution of a long > running script that was started with Context.evaluateString() ? > > I know that I could override ContextFactory.observeInstructionCount() > and throw an Error but what I am actually looking for is a more > elegant and direct way to abort the script immediately from a > different thread, so that evaluateString() returns. This should also > work if the script execution is suspended on a blocking call. > > Thanks for any hint.
you could use: http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino/browse_thread/thread/981ee89aa07c6501/05a9a00bbd82c975 in combination with: Thread.interrupt() if you don't want to, or cannot use, instruction counts. However if you worry about long running scripts due to blocking input/ output or waits or such, just Thread.interrupt() out to be enough; see: http://java.sun.com/javase/6/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html and http://java.sun.com/j2se/1.4.2/docs/api/java/io/InterruptedIOException.html if you are waiting for long running computation, you are out of luck. You should simply implement stop signaling inside the computation. (See technote.) -Onne > Wernke _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
