This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I am studying for SCJP using Kathy Sierra and Bert Bates SCJP 5 study guide. However, I figured this would be the best place to ask this question; it seems simple enough. In the threads chapter, it mentions that Thread's sleep() method takes a time in milliseconds as an argument. There are 1000 milliseconds in one second, so if I pass 1000 to the Thread.sleep() method, it should sleep for *at least* one second. I know there are no guarantees, but for some reason on my system, it is consistently "asleep" for 10 seconds. I have this code:
There is a nice, precise 10 second pause between each print statement. When I use sleep(100) there is a nice 1 second pause each time. Am I missing something???
If you'd add a few println() statements to the code you'd see what it was doing.
Joined: Jul 11, 2006
Yea I know... I should have spent a couple minutes trying to actually figure it out... I was too busy trying to understand how Threads work though, and this was just a thought in the back of my mind that I wanted to ask about.