[concurrency-interest] How to use Callable instead of Runnable with ScheduledThreadPoolExecutor?

Robert Bowen syg6 at yahoo.com
Mon Oct 2 11:45:18 EDT 2006

Hello concurrent people,

I have been futzing around with the Java 1.5 concurrent classes for a while now and more or less have the hang of things. But there is one thing I can't figure out. I'd like to schedule a task to execute every x seconds, have it return me a list of Futures for those tasks and, based on the result in each Future, do something.

I'd like to use either scheduleAtFixedRate() or scheduleWithFixedDelay() but both of these take Runnable as their first parameter, and I'd like to use a Callable (to get a Result). I see that schedule() and submit() both take Callable as a parameter but that's for a one-shot execution, I need something periodic.

Any way to do this?

Many thanks guys,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061002/2228490a/attachment.html 

More information about the Concurrency-interest mailing list