轻灵,内省,质朴,有为

thread中tpool的使用示例

+1 投票

thread扩展中自带有一个线程池。

基本示例

Code: tpool-demo.tcl
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
最新提问 9月 18, 2015 分类:API扩展 | 用户: 风行水上 (-30 分)

登录 或者 注册 后回答这个问题。

...