Hi,
I'm currently experimenting a networked application that works like this. A server creates a ServerSocket object and wait for clients to connect in an infinite loop. Once a client is accepted via the accept() method (and thus I have a Socket object now), I pass this Socket object into a Client object that implements Runnable, and in the run() method, it simply waits for messages from the client (by using a BufferedReader object, for instance).
I wish to take advantage of the new concurrency package of
Java 1.5. I was thinking of passing the Client object into an ExecutorService object. The problem lies here: if I wish to shutdown the ExecutorService object using the shutdownNow() method, I want to interrupt the BufferedReader object of the Client object (most likely the BufferedReader is now blocked due to waiting for messages). I must perform the interruption which will result in an IOException, and subsequently close the Socket, otherwise the
thread doesn't die. Is there any way to do this?
[ March 11, 2005: Message edited by: Liang Anmian ]