[concurrency-interest] Detecting Killed Threads and Restarting themautomatically

David Holmes dcholmes at optusnet.com.au
Mon Jul 3 08:01:07 EDT 2006


If a ThreadPoolExecutor's worker thread terminates due to a runtime
exception then that thread is not automatically replaced immediately.
However when the next task is submitted the normal thread creation policy
will apply: if you are below core size then a thread will be created, if
greater than core but less than max and the queue is full then again a
thread will be created. However, if there are less than max threads running
(but more than core) and the queue is not full, then the TPE will continue
to run with the same (reduced) number of threads.

If this concerns you then don't let your tasks let any exceptions escape.

Cheers,
David Holmes
  -----Original Message-----
  From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of
verma.kr at tcs.com
  Sent: Monday, 3 July 2006 9:05 PM
  To: concurrency-interest at cs.oswego.edu
  Subject: [concurrency-interest] Detecting Killed Threads and Restarting
themautomatically



  Hi Friends,

          I am new to concurrency field so pardon me for my ignorance.

          I am trying to create a Pool of Threads using
ScheduledThreadPoolExecutor class as follows:

          ScheduledExecutorService service = new
ScheduledThreadPoolExecutor(5)

          After that i submit 5 tasks each implemeting runnable ..all these
tasks are supposed to run infinitely in a while loop.

          My doubt is that if at any stage one of the threads is killed due
to RunTime Exception or some critical error in code being executed, then
          is there a mechanism by which i can detect Thread termination and
RESTART it.

          If it can be automatically done that shall be great.

          Please advice.

  Thanks And Regards,
  Verma Rohit Kumar
  Tata Consultancy Services Limited
  Mailto: verma.kr at tcs.com
  Website: http://www.tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you


-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060703/685b190f/attachment.html 


More information about the Concurrency-interest mailing list