Script is starting with 150 threads. They work for random time and sleep random time also.
How you can make the script to run only 10-20 threads at the same time? When this 10-20 threads finish work they go to sleep, another 10-20 threads start and so on.
Here's a suggestion:
Mark the time when starting the thread.
Then during the script run, add a time check action and compare the time difference with your desired value.
-> Take appropriate action.