Factored out thread controller