I am looking for code for a server progr开发者_高级运维am that accepts several client connections using the threadpool concept, such that each client can send a file to the server, and the server should respond by sending the corresponding response file.
I am asking this because at this point I am able to get several client requests, but I am not able to generate responses that include the corresponding response files.
Most of modern J2EE application servers support that concept. Transform your application into a WAR and play with server thread pool/request time out settings.
UPDATE: If you don't like application servers, then use Executors utility class from JDK, create a new ExceutorService through that by wrapping your long running action into Runnable interface and creating a ThreadFactory for that, and then use awaitTermination method. If it returns false, then your thread encountered a time out and you can send some nice error message to your client.
精彩评论