开发者

Request for server program using a threadpool

开发者 https://www.devze.com 2022-12-09 17:01 出处:网络
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 shou

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消