I have a question regarding the scheduleAtFixedRate () method in ScheduledExecutorService in Java 6.
[ edit : Javadoc for 1.6 is more advanced than for 1.5. See Comment below]
Given that:
- ScheduledExecutorService built with N = 1 thread in the pool
- fixed rate is a period of T seconds
- no initial delay
What happens in this case (times should not be absolute, in real time):
- at time T, the service starts the Runnable task, "task1"
- at time 2T, task 1 is not yet completed, and the service should start
Is the service guaranteed for any of the following?
- (a) in 2T, run Runnable task, task2 (remember N = 1)
- (b) block until task 1 is completed
- (c) skip this time and try again at 3T
- (d) undefined behavior
Or something else? Does the answer change if N> 1?
source share