TCL使用tclsh運行下述多執行緒時,能正常輸出結果:Thread 2: 0
Thread 2: 1
Thread 2: 2
Thread 2: 3
Thread 2: 4
Thread 2: 5
Thread 2: 6
Thread 2: 7
Thread 2: 8
Thread 2: 9
Thread 2: 10
Thread 1: 1
Thread 1: 2
Thread 1: 3
Thread 1: 4
Thread 1: 5
使用wish運行時,回傳0,0,沒大搞清楚什么原因,求各位大牛幫忙解答下
原始碼如下:
#Thread1
set Thread1 [thread::create -joinable -preserved {
proc exemple { {max 10} } {
global w
for {set i 1} {$i <= $max} {incr i} {
puts "Thread 1: $i"
}
}
thread::wait
}]
## Thread2
set Thread2 [thread::create -joinable -preserved {
proc exemple { {max 10} } {
for {set i 0} {$i <= $max} {incr i} {
puts "Thread 2: $i"
}
}
thread::wait
}]
thread::send -async $Thread1 [list exemple 5]
thread::send -async $Thread2 [list exemple 10]
thread::release $Thread1
thread::release $Thread2
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/85426.html
