[concurrency-interest] ScheduledThreadPoolExecutor and stalledjobs

David Holmes dcholmes at optusnet.com.au
Wed Nov 15 17:20:01 EST 2006


I'm sorry I don't have any further suggestions. I ran your code with a
trivial MyTask that printed out its name and iteration number and it worked
fine.

I wonder whether you might simply be saturating on the CPU usage and so only
able to complete a fraction of the work. There is no guarantee of fairness
so it could be a particular subset of the tasks that is excluded.

While the programm is running, do a thread dump to see where all the pool
threads are.

David

> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Harsha
> Nagesh
> Sent: Thursday, 16 November 2006 3:35 AM
> To: dholmes at ieee.org; concurrency-interest at cs.oswego.edu
> Subject: Re: [concurrency-interest] ScheduledThreadPoolExecutor and
> stalledjobs
>
>
> Hi David,
>
> Thanks for explaining the executor's operating model. I suspected that
> something similar might be happening. So I tried the same code with the
> scheduleWithFixedDelay method, which, according to the API
> description will
> schedule the next instance of the task only after the current one
> is completed
> (with a certain delay). But I noticed the same behavior there
> too. Some tasks
> may take longer to complete than others, but if the next
> execution of a task is
> scheduled after a certain delay from the completion of the
> current run, I don't
> understand why it would stop further executions of the task.
>
> As far as MyTask is concerned, its just a simple computation. I
> don't think it
> is blocking as I can see the end result of the task printed out, before it
> stalls further scheduling.
>
> Any more pointers or ideas to try out will be greatly helpful.
>
> Thanks,
> Harsha
>
> --- David Holmes <dcholmes at optusnet.com.au> wrote:
>
> > Just had a thought ...
> >
> > ScheduledThreadPoolExecutor operates by dequeing a task and
> executing it,
> > then requeuing afterwards. This means that a task is never running
> > concurrently with itself if it executes beyond its next release time.
> >
> > A different model of periodic task execution would leave the task in the
> > queue so that every period a new execution of it commences, even if the
> > previous one had not completed.
> >
> > If you expected this second model then that is not what you get with
> > ScheduledThreadPoolExecutor.
> >
> > Hope that helps.
> >
> > David Holmes
> >
> > > -----Original Message-----
> > > From: concurrency-interest-bounces at cs.oswego.edu
> > > [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Harsha
> > > Nagesh
> > > Sent: Wednesday, 15 November 2006 11:46 AM
> > > To: concurrency-interest at cs.oswego.edu
> > > Subject: [concurrency-interest] ScheduledThreadPoolExecutor
> and stalled
> > > jobs
> > >
> > >
> > > Hi,
> > >
> > >      I am trying to use ScheduledThreadPoolExecutor to
> schedule a bunch of
> > > jobs, each of which should be scheduled every minute. I am
> > > running this on win
> > > XP and using a poolsize = 20 (threads). However, what I see is
> > > that out of the
> > > 100 or so jobs that have been added to the scheduler, there is a
> > > subset of them
> > > (more than 20%) which seem to be scheduled once and never again
> > > after the first
> > > time. I am not sure how to go about debugging this issue. Any
> > > pointers will be
> > > greatly appreciated. Here is the skeleton of code that shows the
> > > way I am using
> > > the scheduler and I am not sure if this is the best way to
> > > achieve my objective
> > >
> > > int poolSize = 20;
> > > long period = 60; //1 minute
> > > long delay = 60; //1 minute
> > > TimeUnit timeUnit = TimeUnit.SECONDS;
> > >
> > > ScheduledThreadPoolExecutor pool = new
> > >           ScheduledThreadPoolExecutor(poolSize);
> > > for(int i = 0; i < 100; i++){
> > >    MyTask task = new MyTask();
> > >    pool.scheduleAtFixedRate(task,0,period,timeUnit);
> > > }
> > >
> > > I also tried to use
> > >
> > > pool.scheduleWithFixedDelay(task,0,delay,timeUnit);
> > >
> > > instead of the fixedRate scheduling, but I found the same
> > > behavior and many of
> > > my jobs were stuck and not executed after the first run.
> > >
> > > Any ideas ?
> > >
> > > Thanks,
> > > Harsha
> > >
> > >
> > >
> > >
> > > __________________________________________________________________
> > > __________________
> > > Yahoo! Music Unlimited
> > > Access over 1 million songs.
> > > http://music.yahoo.com/unlimited
> > > _______________________________________________
> > > Concurrency-interest mailing list
> > > Concurrency-interest at altair.cs.oswego.edu
> > > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
> >
>
>
>
>
>
> __________________________________________________________________
> __________________
> Sponsored Link
>
> Mortgage rates near 39yr lows.
> $310k for $999/mo. Calculate new payment!
> www.LowerMyBills.com/lre
> _______________________________________________
> 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