To add to copeg's excellent advice, one way to control the number of threads is to use one of the various shades of thread pool, and you might consider using this for the threads that the server uses...