Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCL Thread clarification

Status
Not open for further replies.

Dhinesh72964

Programmer
Joined
Mar 23, 2015
Messages
1
Location
IN
HI, I am Dhinesh,

I want some clarification in TCL Thread, I am new to the thread concept,
I am using TCL activate 8.6 version, when i run the below code in TK console, puts "Thread [thread::id] says hello" this line is not printing on the console. But if i use Sh mode it works fine, can any one help me to understand this.


code:
package require Thread
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!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top