[concurrency-interest] ExecutorCompletionService for scheduled task

Dhanji R. Prasanna dhanji at gmail.com
Sun Aug 13 19:11:50 EDT 2006


On 8/14/06, Hanson Char <hanson.char at gmail.com> wrote:
> plus other code to schedule via the ScheduledExecutorService, and then
> to wait for timeout via the ScheduledFuture.get(...)
>

I think that's about the simplest/most practical solution so long as
you are happy that the thread calling SF.get() is reliably early and
isolated (i.e. is able to call SF.get() on all scheduled threads
independently). If not, I think Joe's idea of using a parallel watcher
is the better solution.

> Just wonder if there is a better (lazier) way.
>
> Hanson
>
> On 8/13/06, Dhanji R. Prasanna <dhanji at gmail.com> wrote:
> > Have you looked into using ScheduledThreadPoolExecutor with CompletionService?
> > The schedule() method takes a delay which can be used to trigger the
> > close operation.
> >
> > Not sure if this is exactly what you want to do?
> >
> > On 8/13/06, Hanson Char <hanson.char at gmail.com> wrote:
> > > Hi,
> > >
> > > I am not sure if the existing ExecutorCompletionService can be nicely
> > > fitted here.  What we want is a scheduled close operation to be
> > > initiated on each open session after m seconds delay, and abort
> > > regardless after a total of n seconds, even if some of these close
> > > operations haven't started or finished, where n > m.
> > >
> > > ExecutorCompletionService.submit() allows some tasks to be submitted
> > > for execution, but there doesn't exist something like
> > > ExecutorCompletionService.schedule() that would take a delay
> > > parameter.
> > >
> > > Thoughts ?
> > >
> > > Hanson Char
> > > _______________________________________________
> > > Concurrency-interest mailing list
> > > Concurrency-interest at altair.cs.oswego.edu
> > > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> > >
> >
>


More information about the Concurrency-interest mailing list