我试图连续运行一个线程,而不是被tcl主事件循环阻塞。 这里是什么,我试图做一个简单的例子:防止tcl线程被主事件循环阻塞
#!/bin/sh
#\
exec tclsh "$0" "[email protected]"
package require Thread
set ::a_thread [thread::create {thread::wait}]
proc start_a {} {
thread::send $::a_thread {
puts "Running a thread"
}
after 1000 a_start
}
proc infinite_loop {} {
while {1} {
puts "Loop"
after 500
}
}
start_a
infinite_loop
vwait forever
在这段代码中,infinite_loop
PROC被称为与主事件循环无限运行。我想如果a_thread
仍然可以在后台运行。我怎样才能做到这一点?
谢谢,Tcl wiki的例子似乎忽略了这种情况。 – elmt 2010-11-19 14:07:49