scheduleWithFixedDelay and exceptions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

scheduleWithFixedDelay and exceptions

ttabbal
The JavaDoc says:

"If any execution of the task encounters an exception, subsequent
executions are suppressed."

That tells me that the periodic task will stop running if it gets an
exception. That's a reasonable thing to do, but how do I check to see
if this happened? I'm getting the executor by calling
Executors.newSingleThreadScheduledExecutor(); ...

I want to be sure I can insert some error handling in the process
should one of them throw an exception.

Thanks!

Travis Tabbal
_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: scheduleWithFixedDelay and exceptions

tpeierls
On 11/1/06, Travis Tabbal <[hidden email]> wrote:
The JavaDoc says:
"If any execution of the task encounters an exception, subsequent executions are suppressed."

That tells me that the periodic task will stop running if it gets an exception. That's a reasonable thing to do, but how do I check to see if this happened? I'm getting the executor by calling Executors.newSingleThreadScheduledExecutor(); ...

Use the isDone() method of the ScheduledFuture returned by ScheduledExecutorService.scheduleAtFixedRate and ScheduledExecutorService.scheduleWithFixedDelay . It returns true if the task is no longer running (because it threw an exception or was cancelled).

--tim

_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest