You have a good point.  The shell is a special case that takes a shortcut
when used with a file argument.  In the case of a file argument, there is
only one thread for the Shell.  The console thread is never created.  As a
result, it is valid for the main thread to call interp.evalFile() without
using an event queue.

However, I think this is a corner case because a large number of Java
application cannot get away with using only a single thread.  When the Shell
must take user input interactively, it needs a second thread to do this.
Then, the event queue mechanism must be used.  I think for most Java
application that needs to embed the Tcl interpreter, there are more than one
thread at work.

The basic concept is that the Tcl interpreter is designed for single thread
execution.  If you have only one thread, you can call any methods of the
interpreter at any time in this thread.  If you have more than one thread,
use the event queue.

You can also implement the Shell with the file argument using the event loop
method by using 2 threads.  One runs the event queue, and the other sends
"source <filename>", then sends "exit" to the event queue.

-- Jiang Wu
   [EMAIL PROTECTED]

-----Original Message-----
From: Jeff Sturm [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 01, 2000 1:51 PM
To: Mo DeJong
Cc: [EMAIL PROTECTED]
Subject: [Tcl Java] Re: Thread safety (was: Using JACL in servlets)


Mo DeJong wrote:
> It does. The docs say that ALL methods that interact with an interp
> instance and thread unsafe. For this reason, all interp interaction
> needs to be done from the Tcl event queue thread. Here is a quick
> example that call the "unsafe" eval() method using the Notifier
> to queue up a "thread safe" event.

I don't see the event loop used consistently.  The tcl.lang.Shell in CVS
for example never runs an event loop when run with a filename argument:

java tcl.lang.Shell hello.tcl

-- 
Jeff Sturm
[EMAIL PROTECTED]

----------------------------------------------------------------
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