Well, how do we prevent the Tcl event queue from being accessed
from multiple Java threads? In the case where Tcl is threaded,
Tcl should do its own locking. In the case where Tcl
is not threaded, I would think we would need the JVM to do
the locking (AKA JAVA_LOCK). I am not convinced that we need
one global lock, we could use on Java monitor for each
Notifier.

Mo DeJong
Red Hat Inc

On Thu, 18 May 2000, Jiang Wu wrote:

> My opinion is that there is no need for any locking for non-threaded version
> of Tcl in TclBlend.  There is no need for any locking for threaded version
> of Tcl in TclBlend.
> 
> Here are my reasons:
> 
> 1. JAVA_LOCK does not serve any useful function, whether Tcl is thread
> enabled or not.
> 2. JAVA_LOCK does not let multiple threads to access a single Tcl
> interpreter.
> 3. The event queue is the "right way" to access both non-threaded Tcl and
> threaded Tcl.
> 4. When the event queue is used, JAVA_LOCK is overhead because only the
> interpreter "owner" thread ever tries to acquire this lock.  So the locking
> always succeeds.
> 5. When the event queue is NOT used, JAVA_LOCK typically causes the caller
> thread to deadlock.
> 
> There is a corner case in which JAVA_LOCK does allow multiple threads to
> access a single interpreter.  This is when the programmer never uses the
> event queue of the interpreter directly or indirectly.  You can achieve this
> by never run any asynchronous Tcl commands, never queue anything to the
> event queue, etc.  I am not sure if we need to keep JAVA_LOCK only for this
> special corner case.
> 
> If JAVA_LOCK is removed entirely, then the question becomes "how do we
> protect the non-threaded Tcl interpreter from being accessed by multiple
> Java threads?"  My answer to that is "use the interpreter's event queue",
> just like you would when using thread enabled Tcl.
> 
> -- Jiang Wu
>    [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

Reply via email to