Cleaner implementation of threads so that the application does not crash if the pool is too large.