Simple multi-threaded Java server loop
I wouldn't recommend creating new Threads on your own or using Threads without holding onto their references. It makes it too hard to shut down properly. In your example, I think that if SocketCloser.close(socket) throws, then the request_counter will be off by one.

I recommend starting with a thread pool.

ExecutorService pool = ExecutorService.newCachedThreadPool();


You can use a fixed size pool if an infinite pool causes you problems. Then you can submit Runnables to it in the same place you're creating Threads now. Finally, when you want to shut down, you can use the methods shutdownNow() and awaitTermination() on the pool.