37,721
社区成员
发帖
与我相关
我的任务
分享
set var $::GLOB_VAR
set id [thread::create {
#我想在这里用到外层的var变量或者全局的GLOB_VAR,要如何实现啊
puts "Thread thread::id] Running..."
}]
package require Thread
tsv::set app mainID [ thread::id ]; #取当前线程id
proc aa { } {
puts "This is proc aa."
}
tsv::set app var $::GLOB_VAR
set id [thread::create {
puts [ tsv::get app var ] #我想在这里用到外层的var变量或者全局的GLOB_VAR,要如何实现啊
puts "Thread [ thread::id ] Running..."
thread::send -async [ tsv::get app mainID ] [ list aa ]; #执行主线程中的aa
}]
tsv::set app a 123; #定义变量a并赋值, app视为数组名
tsv::get app a; #取变量a的值
thread::send -async $id [ list cmd $variable ]; #跨线程调用命令/函数