This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Murach's MySQL and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic