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?
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?
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?
Edit : And if you have found out the solution already, let us know too.