• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why ScheduledThreadPoolExecutor is not respecting the delay?  RSS feed

 
Surendra Nadh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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?
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!