thread扩展中自带有一个线程池。
基本示例
package require Tcl package require Thread set tpool [tpool::create -minworkers 3 -maxworkers 5 \ -idletime 3 \ -initcmd { puts "thread init ..." } -exitcmd { puts "thread exit ..." }] puts [tpool::names] set jobs [list] set script { puts "[thread::id] [clock seconds]" after 2000 } lappend jobs [tpool::post $tpool $script] lappend jobs [tpool::post $tpool $script] while 1 { tpool::wait $tpool $jobs pend if {[llength $pend]==0} break } tpool::release $tpool