




Select “ Never” from the drop-down menu next to “ Put the computer to sleep“.Click on the link “ Change when the computer sleeps” appearing on the left panel.Select “View” as “Small icons” or “Large icons”, find “ Power Options” option and click on it.Search for “ Control Panel” and open it.This is the test program: import java.util. Wed Apr 01 17:18: This should be a low number: 0 Wed Apr 01 17:18: The system has come through the Thread.sleep(360000). Wed Apr 01 17:12: The program will now wait for 6 minutes. Wed Apr 01 17:12: Java Runtime Version: 1.8.0_31-b13 JVM Version: 25.31-b07 Windows Version: Windows 7 If the process is run on Windows 7, it does not fail. Wed Apr 01 10:53: This appears to be operating incorrectly.the expected sleep time has NOT been achieved. Wed Apr 01 10:53: This should be a low number: 63589 Wed Apr 01 10:53: The system has come through the Thread.sleep(300000). Wed Apr 01 10:47: The program will now wait for 5 minutes. Wed Apr 01 10:47: JVM Version: 25.40-b25 Windows Version: Windows 8 Wed Apr 01 10:47: You can use "SleepTester -minutes 10" to have it sleep for 10 minutes, for example. Wed Apr 01 10:47: Using default number of minutes: 5 If this the program is run on Windows 10 (reporting as 8) with JVM Version: 25.40-b25, it fails: C:\Users\Tester\Downloads>SleepTester.exe The procedure is to run the program, cause the machine to sleep for about a minute, then wake the machine and wait for the program to finish. Is this a Windows 10 bug? Is this a JVM bug? Is there a work-around?Ī test program and procedure were developed. It appears that the machine begins executing code at "msToWait" plus the time the machine has been in S3 (not 100% sure of this right now, but likely).Įarlier versions of Windows did not exhibit this behavior code after Thread.sleep() waited the right amount of time, irrespective of sleep status. This has been working fine, even if the system happens to go into S3 sleep state during the wait.Īs of Windows 10, though, the code after Thread.sleep() does not execute "on time" if the machine has been in S3. The application calculates how far in the future it needs to do something, then hits a Thread.sleep(msToWait). This same application has been working fine from Windows XP through (at least) Windows 7. There's a desktop application that uses Thread.sleep() to achieve long (minutes or hours) delays.
