• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Why ScheduledThreadPoolExecutor is not respecting the delay?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Customized implementation for ScheduledThreadPoolExecutor using which I am trying to execute a task for continuous execution. The problem I have faced here with the implementation is, some tasks executed continuously where as two of them are not respecting the delay and executed continuously. I am using the scheduleWithFixedDelay method.
Even I have tried reproducing, but I couldn't.

Here is my customized implementation.





Is there any possibility for the continuous execution or not?
 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Surendra Nadh,

Welcome to JavaRanch.

Your code does not look like a practice assignment. Still are your actual tasks still as simple as you have shown us? I mean is there a possibility that one or more of your actual tasks threw an exception?

When I execute your code, I am able to see all your 10 tasks scheduled after fixed delay and as expected they cancel after they have run for 10 times. Wouldn't that be the desired behavior?

Chan.
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is there any possibility for the continuous execution or not?



I am not too sure what this means yet. I can see that your tasks are being scheduled after fixed delay like you intended.
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please ignore my responses. I was talking from the back of my head when I said "is it possible your tasks threw an exception' cause that would have stopped the subsequent executions of that task.

When I try to think of what could have gone wrong, I can't think of a thing though. But then I can't figure how you got to know that your tasks executed continuously. Assuming your actual tasks are different, is it through some state set in some another system or something?

Chan.

Edit : And if you have found out the solution already, let us know too.
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic