[concurrency-interest] scheduleWithFixedDelay and exceptions

Tim Peierls tim at peierls.net
Thu Nov 2 10:02:50 EST 2006


On 11/1/06, Travis Tabbal <travis at tabbal.net> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061102/b0ceff4f/attachment.html 


More information about the Concurrency-interest mailing list