[concurrency-interest] Equivalent of scheduleAtFixedRate() for Callable

Andrew Lentvorski bsder at allcaps.org
Sat Mar 25 18:05:08 EST 2006


Joe Bowbeer wrote:
> I was assuming you were arriving from java.util.Timer land

Wrong assumption.  I use Runnable and scheduleAtFixedRate() just fine.  ;)

>, but maybe
> you already have seen ScheduledExecutorService, where periodic
> execution of Runnable *is* all you get.

Yep, and that is my problem.

> If you need to report a periodic result from a Callable you'll need to
> incorporate your own mechanism for doing that, such as a Listener.  SO
> you'd wrap your Callable in a Runnable like the following before
> scheduling it for periodic execution.
> 
>   new Runnable() {
>       public void run() {
>           listener.hear(callable.call());
>       }
>   }

Yuck.  But I'll keep it in mind.

Is the lack of scheduleAtFixedRate() et al. for Callable a conscious 
design decision or is it just an oversight?  Or, in slightly different 
form, is there some minefield with Callable and scheduleAtFixedRate() 
that the experts know about that I'm about to go plowing into?

Thanks,
-a



More information about the Concurrency-interest mailing list