I am writing a simple HTTP server where the main thread loops in a ServerSocket.accept loop and passing any incoming sockets to worker threads, which will then process them and send back responses. However, I want to special case a shutdown request that will shut down my whole server. I am having trouble using a worker thread to force the main thread to break out of the accept loop and terminate.
Any pointers?
like mentioned in this thread you can just call close() on the server socket which will lead to an Exception in the accept call.