Thread result is different in tclsh and wish ??
From: Payton Chou (payton.chou_at_gmail.com)
Date: 11/09/04
- Next message: David Gravereaux: "Re: Thread result is different in tclsh and wish ??"
- Previous message: Jeannot: "SYBTCL Installation"
- Next in thread: David Gravereaux: "Re: Thread result is different in tclsh and wish ??"
- Reply: David Gravereaux: "Re: Thread result is different in tclsh and wish ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 9 Nov 2004 00:38:52 -0800
Today I compile the following code with tclsh and wish. ( These code
comes from a book )
#########################################################
package require Thread 2.5
puts "*** I'm thread [thread::id]"
# Create 3 threads
for {set thread 1} {$thread <= 3} {incr thread} {
set id [thread::create {
# Print a hello message 3 times, waiting
# a random amount of time between messages
for {set i 1} {$i <= 3} {incr i} {
after [expr { int(500*rand()) }]
puts "Thread [thread::id] says hello"
}
}] ;# thread::create
puts "*** Started thread $id"
} ;# for
puts "*** Existing threads: [thread::names]"
# Wait until all other threads are finished
while {[llength [thread::names]] > 1} {
after 500
}
puts "*** That's all, folks!"
thread::names
#########################################################
The tclsh result:
*** I'm thread 8872
*** Started thread 8968
*** Started thread 8964
*** Started thread 8928
*** Existing threads: 8928 8964 8968 8872
Thread 8968 says hello
Thread 8964 says hello
Thread 8964 says hello
Thread 8968 says hello
Thread 8928 says hello
Thread 8964 says hello
Thread 8968 says hello
Thread 8928 says hello
Thread 8928 says hello
*** That's all, folks!
8872
#########################################################
The wish result:
*** I'm thread 8860
*** Started thread 8980
*** Started thread 8832
*** Started thread 9008
*** Existing threads: 9008 8832 8980 8860
*** That's all, folks!
8860
#########################################################
Why the result is different between tclsh and wish ??
And are there anyone can give me the link about difference between
tclsh and wish.
Thanks all.
- Next message: David Gravereaux: "Re: Thread result is different in tclsh and wish ??"
- Previous message: Jeannot: "SYBTCL Installation"
- Next in thread: David Gravereaux: "Re: Thread result is different in tclsh and wish ??"
- Reply: David Gravereaux: "Re: Thread result is different in tclsh and wish ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|