Limiting the number of threads