[concurrency-interest] Need to kill a single working thread, rather than killing the application

David Holmes dcholmes at optusnet.com.au
Mon Dec 18 18:03:59 EST 2006


Hi,

If you are concerned about the socket operation blocking for too long then
you can setSOTimeout and if it times out just abandon the current task.

If more generally you want to cancel a task after N seconds then you need to
write the task in a way that is cancellable (which means the socket blocking
still needs taking care of) and you need to set up a "watchdog task" to
trigger the cancellation. The watchdog task can be a FutureTask submitted to
a ScheduledThreadPoolExecutor. But you also need to cancel the watchdog if
the main task completes normally.

Cheers,
David Holmes
  -----Original Message-----
  From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Chirag Shah
  Sent: Saturday, 16 December 2006 9:03 AM
  To: Concurrency-interest at cs.oswego.edu
  Subject: [concurrency-interest] Need to kill a single working
thread,rather than killing the application


  Hi,

  I am new to TPE. I have a question.

  I have a Multithreaded Java Application running on SunOS Sparc.
  Which open a socket connection, get the request and pass it to the worker.
The worker will read/write the file and send the data back to the client.
Rightnow we have setting of min 300 Thread and max 1000 Thread.

  My basic requirement is, if a thread takes more than couple of sec eg 5
seconds, I want that thread to stop doing the task, ie terminate that
request and start serving other requestm, which is in the queue. b'cos that
single task may hung my whole application. I can kill a single request
rather than killing the whole application.

  Would you please give me the best idea?

  Thanks.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061219/f05a9746/attachment.html 


More information about the Concurrency-interest mailing list