The callback function of a timer with an interval of 5 seconds, sleeps for a period of 20 seconds. The timer events are dispatched in three threads .A statement at the start of the callback function prints out a message to the screen. What is the time difference between two consecutive messages output to the screen ?
A
Correct answer
Explanation
The timer fires at its defined interval of 5 seconds regardless of how long the callback takes to execute. The timer schedules the next event 5 seconds after the previous scheduled time, not 5 seconds after the callback completes. Even though the callback sleeps for 20 seconds, the timer continues firing every 5 seconds. With three threads, multiple callbacks can run concurrently, but messages are printed at 5-second intervals as each timer event triggers.