While the following suggestion is not a solution, it may help your case.

Use the notion of "trusted" vs "untrusted" mode.  In "trusted" mode, a
thread uses an embedded Tcl interpreter to run Tcl scripts inside the main
JVM process.  In "untrusted" mode, the thread sends the script to a separate
slave Tcl interpreter process.  Then the thread can kill the slave process
if the process does not respond in a pre-determined amount of time.

Let user be able to run scripts in the "untrusted" mode for debugging.
Later, runs the same scripts in the "trusted" mode for efficiency.

-- Jiang Wu
   [EMAIL PROTECTED]

> -----Original Message-----
> From: Mo DeJong [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 27, 2000 6:18 PM
> To: Marc Saegesser
> Cc: [EMAIL PROTECTED]
> Subject: [Tcl Java] Re: Interrupting a Interp.eval()
> 
> 
> On Thu, 27 Jul 2000, Marc Saegesser wrote:
> 
> > I'm embedding several Tcl interpreters inside a JVM.  I'm 
> currently using
> > Jacl, but will probably switch to TclBlend at some point in 
> the future.
> > 
> > I'm trying to work out the best approach for cleanly 
> shutting down these
> > embedded interpreters.  If everything is running normally, 
> I can post a
> > TclEvent object whose processEvent() method calls 
> Interp.dispose() and
> > causes the event loop to terminate.
> > 
> > The problem with this is that I don't see a way to stop an 
> interpreter that
> > has run amok.  Suppose that Interp.eval() is processing a 
> script that is
> > stuck in an infinite loop.  The notifier's event loop isn't 
> processing new
> > events to my shutdown TclEvent will never get processed.  
> Is there a good
> > method for aborting a call to Interp.eval()?
> 
> There is no way to do this in Jacl. The "how do I stop a 
> runaway thread"
> problem is a very tricky one. The best you can really do is 
> put and event
> into the queue and code your app so it notices the "quit now" event.
> 
> There is also no way to stop a looping interp in regular Tcl.
> 
> Sun tried to add an API that would let you kill a thread from another 
> thread, but it was later removed because it was a disaster.
> 
> Mo DeJong
> Red Hat Inc
> 
> ----------------------------------------------------------------
> The TclJava mailing list is sponsored by Scriptics Corporation.
> To subscribe:    send mail to [EMAIL PROTECTED]  
>                  with the word SUBSCRIBE as the subject.
> To unsubscribe:  send mail to [EMAIL PROTECTED] 
>                  with the word UNSUBSCRIBE as the subject.
> To send to the list, send email to '[EMAIL PROTECTED]'. 
> An archive is available at 
> http://www.mail-archive.com/tcljava@scriptics.com
> 

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to