Create a pool of threads when the server launches, store incoming connections in a queue, and have the threads in the pool progressively remove connections from the queue and process them.
The main change you need to make to implement this is
to call accept()
in the run()
method rather than in the main()
method.