Monday, January 9, 2012

Thread Sleep in Java

There are quite a few articles online that deal with the sleep method in Threads. They deal with the granularity of the time that the thread is supposed to sleep i.e. with the lower limit of the sleep time. One such good post is this one:

http://www.javamex.com/tutorials/threads/sleep_issues.shtml

But I noticed that there weren't many places that talk about a possible upper limit on the sleep time (if there is one).  So I tried it on the following the operating systems:


Red Hat Enterprise Linux Server release 5.6 (Tikanga)

Microsoft Windows XP professional, Version 2002 service pack 3 using  
Eclipse Java EE IDE for Web Developers.Version: Helios Release,Build id: 20100617-1415


My code was pretty simple, I put a thread to sleep for 30 minutes and had a logging statement above and below the sleep statement. The thread recovered fine.

To conclude, I couldn't notice an upper limit on the sleep time.

No comments: