あなたはTclの8.4を使用しているコメントから、あなたが得ようとしているアドバイスは簡単ですので、私のコードの下に
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!"
されている。アップグレードをTclのサポートされているバージョンに置き換えます。私はあなたがOSX上でtclsh8.5とtclsh8.6の両方で投稿した正確なコードを試しました。ここでは8.5で実行します:
*** I'm thread tid0x7fff758f3180
*** Started thread tid0x104326000
*** Started thread tid0x1043ac000
*** Started thread tid0x1044b2000
*** Existing threads: tid0x1044b2000 tid0x1043ac000 tid0x104326000 tid0x7fff758f3180
Thread tid0x1043ac000 says hello
Thread tid0x104326000 says hello
Thread tid0x104326000 says hello
Thread tid0x1044b2000 says hello
Thread tid0x1043ac000 says hello
Thread tid0x1044b2000 says hello
Thread tid0x104326000 says hello
Thread tid0x1044b2000 says hello
Thread tid0x1043ac000 says hello
*** That's all, folks!
スレッド-IDは、他のプラットフォーム上ではかなり異なる場合があります(そのフォーマットは仕様の一部ではない)が、それはあなたが得るものの一種である必要があります。もちろん、順序のモジュロバリエーション。
Tcl 8.4はセキュリティ修正プログラムでもサポートされなくなりました。それは8.4.20がリリースされた後に終わったのです。
私はその正確なコードを試してくれます。 –
印刷は何ですか?出力を表示できますか – Nitesh
私はウィンドウでTcl 8.4を使用しています – Nitesh