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]

-----Original Message-----
From: Mo DeJong [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 18, 2000 2:43 PM
To: [EMAIL PROTECTED]
Subject: [Tcl Java] RE: [Tcl Java] Re: [Tcl Java] RE: [Tcl Java] RE:
[Tcl Java] Threa d question in TclBlend


I thought the whole point you were making was that if we require that
Tcl be built with threads then we could remove the JAVA_LOCK stuff.
How do you suggest we implement locking in a non thread enabled version
of Tcl if we are not going to use the current JAVA_LOCK approach?

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

Reply via email to