0
當我嘗試調用tcl線程中的proc時,出現一個錯誤,指出無效的命令名。以下是我的tcl代碼。請幫助確定proc在線程中無法識別的原因。謝謝。在tcl線程中調用proc
package require Thread
proc CPUload { Start Stop } {
for {set i $Start} {$i <= $Stop} {incr i} {
set j [expr {sqrt($i)*sqrt($i)}]
set k [expr {$i % 123}]
}
}
set id1 [thread::create]
catch {thread::send $id1 "CPUload 1 50000000"} ret
puts $ret
puts $errorInfo
while {[llength [thread::names]] > 1} {
after 500
}
錯誤味精是如下
invalid command name "CPUload" while executing "CPUload 1 50000000" invoked from within "thread::send $id1 "CPUload 1 50000000""
閱讀線程文檔...您需要在線程中加載/初始化您的特效,它們不會自動/神奇地共享。 – schlenk