now we use the max_threads variable to not crash the system with too many threads
use the max_threads variable so we dont overload.