# Create a thread pool.
package require Thread
set tpool [tpool::create -maxworkers 1]

# Create 5 jobs.
for {set i 1} {$i <= 5} {incr i} {

    # BUG: The -nowait switch should post the job immediately, instead each
    # job takes 2 seconds to post.
    set job [tpool::post -nowait $tpool {after 2000}]
    puts "[clock seconds] Posted job $i"
}

# Delete the pool.
tpool::release $tpool

# Wait for pool to terminate (?), otherwise receive error:
# "called Tcl_FindHashEntry on deleted table".
after 1 {set forever 1}
vwait forever


# Output:
#
# 1339505660 Posted job 1
# 1339505662 Posted job 2
# 1339505664 Posted job 3
# 1339505666 Posted job 4
# 1339505668 Posted job 5
