flexible number of threads