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

Joe Bowbeer joe.bowbeer at gmail.com
Sat Mar 25 17:52:12 EST 2006


I was assuming you were arriving from java.util.Timer land, but maybe
you already have seen ScheduledExecutorService, where periodic
execution of Runnable *is* all you get.

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());
      }
  }


On 3/25/06, Joe Bowbeer <joe.bowbeer at gmail.com> wrote:
> See ScheduledExecutorService
>
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html
>
> On 3/25/06, Andrew Lentvorski <bsder at allcaps.org> wrote:
> > I hope I'm not missing anything obvious, but I can't seem to find the
> > equivalents to scheduleAtFixedRate() and scheduleAtFixedDelay() for
> > Callable classes.
> >
> > Did I miss something?  If not, what is the equivalent idiom?
> >
>



More information about the Concurrency-interest mailing list