Limit the maximum number of created threads