【发布时间】:2017-03-24 20:57:51
【问题描述】:
我的代码如下所示:
package require Thread
proc p1 {} {
set tid [thread::create {
proc executeCommand {command} {
return $command
}
thread::wait
}]
set result ""
::thread::send -async $tid [list executeCommand {"Hello thread world"}] result
#***Do some additional stuff***
vwait result
::thread::release $tid
puts $result
return $result
}
p1
在获取包含此代码的 .tcl 文件后,我的期望是子线程在调用 vwait 并打印出“结果”变量后返回“Hello thread world”,但这些都没有发生。 'result' 变量似乎保持空白。
奇怪的是,当我将代码从过程 (proc) 块中取出并获取 .tcl 文件时,它可以完美运行,但是根据我的系统设置方式,我需要使用过程。
不知道我做错了什么。
【问题讨论】:
标签: multithreading tcl send