Java: properly closing sockets for multi threaded servers
问题 I'm trying to create a multi threaded server to which multiple clients can connect and can be served. However, I'm not sure on how to properly free up my resources should the need arise. My server runs an input thread (waiting for user inputs) and a procressing thread (handles connections and users). I open up a ServerSocket in the server class and pass it to my processing thread. It looks like this: public class ClientConnector implements Runnable { private ServerSocket serverSocket; public