The behavior of sleep method in threads

0 comments



Recently i was reading one of the article on threads and found a very interesting point that while using the sleep method in threads, the Operating System records the wake up time in the absolute form and not relative.

For example, Thread.sleep(5000) is supposed to sleep for 5 seconds and if this statement is executed at time 9:00:00 AM the thread will wake up at 9:00:05 AM .But, if the system time is changed, for example to 8:00:00AM, after the statement is executed, the thread will wake up only at 9:00:05 AM but not after the expected duration of 5 seconds.

No comments:

Post a Comment

Recent Posts

Popular Posts

© 2011-2019 Web Portal Club