first virsion of threader.  Works but is slow.
made threader faster by buffering up chunks of tokens and locking mutex less often.