我正在使用TCL線程。我正在嘗試編寫一個簡單的程序,它將在每個線程中打開3個線程和一個簡單的打印語句。爲什麼TCL線程不打印輸出
下面是我的代碼
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!"
下面是輸出
*** I'm thread tid00004028
*** Started thread tid0000A5E8
*** Started thread tid00009F28
*** Started thread tid00009D54
*** Existing threads: tid00009D54 tid00009F28 tid0000A5E8 tid00004028
*** That's all, folks!
適用於我,當我嘗試確切的代碼。 –
什麼是打印?你可以顯示輸出 – Nitesh
我在窗口中使用Tcl 8.4 – Nitesh