#!/usr/local/bin/tclsh

package require Thread

# initialize the thread pool
set mypool [tpool::create -minworkers 1 -maxworkers 5]

# queue up something that exits the thread.
# this will be unable to process more than 5 events because all of the workers have gone away.
for {set i 0} {$i < 10} {incr i} {
	tpool::post $mypool "puts \"hello $i\"; thread::exit"
}

tpool::release $mypool