Subj : Re: Rhino 1.5 script interrupt/terminate To : rhino From : Igor Bukanov Date : Wed Jan 22 2003 10:27 pm rhino wrote: > protected void observeInstructionCount(int instructionCount); ..... > > So with optimization set to -1 and setInstructionObserverThreshold set this > method does indeed get invoked during script execution. The question is how > to terminate the script. Thread.currentThread().interrupt() doesn't do it. > Another approach I've tried that works is to call reportError("some > message") from the observeInstructionCount method. This does the trick > generating an EvaluatorException and exiting the script Seems like a hack > and there should be a more direct way to do this. > > Comments? > > You can throw an instance of Error subclass and put try/catch for it arround code that executes JavaScript. With EvaluatorException each finally block in a script will still be executed but with Error instances the script never get the control back. Regards, Igor .