Thread monitoring

vidya mahavadi

Ranch Hand

Posts: 34

posted 9 years ago

Hi,

I am looking at an application which uses ExecutorService which handles 3 threads. These threads handle events put in BlockingQueues one after the other. I need to know when one of these threads fail, I would like to stop the rest of the threads and log the exception.. Can anyone suggest a better mechanism to monitor these threads..

Thanks, Vidya

Stan James

(instanceof Sidekick)
Ranch Hand

Posts: 8791

posted 9 years ago

Well, first define "fails".

If your run() code detects a problem and wants to let somebody know, you can use some kind of pub-sub or callback. Then they should exit run() so the thread can be used for another task.

What other kind of scenario do you want to handle?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi