On Mon, 07 August 2000, Mo DeJong wrote:
>
> package require java
> set AQT [java::new AppendEventQueueThread [java::getinterp]]
> $AQT start
> set orig_numQueued [java::field $AQT numQueued]
> java::call AppendEventQueueThread queueVwaitEvent [java::getinterp]
Note: this will NOT block the C Tcl shell because you are just posting an event to be
executed later. You have to use 'vwait' or 'update' here to force the event loop to
run.
> set numQueued [java::field $AQT numQueued]
> set numProcessed [java::field $AQT numProcessed]
>
> # Kill this other thread.
> java::field $AQT killed 1
You just killed the other thread before the thread had a chance to post any events.
As a result, only one event is ever queued, the VWait event.
Change your script to the following and try again:
package require java
set AQT [java::new AppendEventQueueThread [java::getinterp]]
$AQT start
set orig_numQueued [java::field $AQT numQueued]
java::call AppendEventQueueThread queueVwaitEvent [java::getinterp]
# go into the event loop
set x 1
after 10000 {set x 2}
vwait x
set numQueued [java::field $AQT numQueued]
set numProcessed [java::field $AQT numProcessed]
# Kill this other thread.
java::field $AQT killed 1
puts $numQueued
puts $numProcessed
# I get 9 for numQueued and 9 for numProcessed
-- Jiang Wu
[EMAIL PROTECTED]
----------------------------------------------
[EMAIL PROTECTED] is brought to you by
the Stanford Alumni Association and Critical Path.
----------------------------------------------------------------
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