[concurrency-interest] Detecting Killed Threads and Restarting them automatically

Peter Veentjer alarmnummer at gmail.com
Mon Jul 3 08:27:44 EDT 2006


made a typo in the previous mail, it can't change state:

If a thread isn't runnable anymore (isn't alive) it can't change state
anymore (it is going to be garbage collected)

On 7/3/06, Peter Veentjer <alarmnummer at gmail.com> wrote:
> If a thread isn't runnable anymore (isn't alive) it can change state
> anymore (it is going to be garbage collected).
>
> If a task throws an RuntimeException (it can't throw a checked
> exception because the runnable interface doesn't allow this) it is
> caught and the 'afterExecute' method is called. You can override this
> method in a subclass of ThreadPoolExecutor or in your case a subclass
> of the ScheduledThreadPoolExecutor (why isn't a error policy/strategy
> used instead of the current construction??)
>
> Throwable's (that are not exceptions) shouldn't be caught anyway
> because you can't make any guarantees about the stability of the
> system anymore.
>
> btw
> I'm working on a concurrency library that contains the Repeater (and
> the ThreadpoolRepeater). The repeater is a construct that is made for
> continuous running of a single runnable by multiple threads. It has
> the same configuration for delays and periods). Personally I prefer
> this construct more because it gives me more control and makes it more
> clear what it does. I'm going to opensource this library in the near
> future.
>
>
> On 7/3/06, verma.kr at tcs.com <verma.kr at tcs.com> wrote:
> >
> > 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
> >
> >
> >
> >
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at altair.cs.oswego.edu
> > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
> >
> >
>


More information about the Concurrency-interest mailing list