当我抛出两种不同方式的脚本时,我遇到了问题
我设置了ActiveState。
使用tclsh86.exe,当我启动我的脚本时:
% source C:/Temp/thread.tcl
Thread 1: 0
Thread 1: 1
Thread 1: 2
Thread 1: 3
Thread 1: 4
Thread 1: 5
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
使用wish86.exe ,当我启动我的脚本时:
(System32) 1 % source C:/Temp/thread.tcl
0
我不明白,问题是什么? 谢谢你的帮助
我的代码thread.tcl
如下:
package require Thread
# Thread1
set Thread1 [thread::create -joinable -preserved {
proc exemple { {max 10} } {
global w
for {set i 0} {$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 -wait $Thread1
thread::release -wait $Thread2