Would a scheduled Java app run when Windows is in sleep mode?
Asked Answered
V

4

8

If I start a Java app, it initiates and does some work then goes to thread sleep for an hour, then wake up after an hour and does some more work ...

But my PC is running Win7 and after 15 minutes of inactivity, it will go into sleep mode, so my question is : an hour from I started the Java app, if I don't touch the PC, and it goes into sleep mode, will my Java app still be able to wake up and do its work, and if so will the Win7 PC wake up with the screen turned on again [ because in Win7 sleep mode the screen turns off ] ?

Velodrome answered 18/10, 2010 at 14:55 Comment(2)
I sincerely doubt your computer can get out of sleep mode without some hardware signal (e.g. a keyboard or wake-on-LAN IRQ). Software can't do this: in sleep mode, your processor doesn't run any code, not even your OS's code.Callosity
I believe I've seen that Windows Media Center can wake up the computer to record a show. Must be a motherboard timing thing.Territorialism
E
10

A normal Thread.sleep() will not wake up the computer from sleep mode.

However, when registering a task with the Windows task scheduler, you can choose "wake the computer to run this task". When going to sleep mode, Windows will tell the motherboard the time of the next registered wake-up task.

Energumen answered 18/10, 2010 at 15:3 Comment(0)
O
4

How could it possibly run if Windows isn't? There may be some tricks available with automatic wake-ups supported by the motherboard, but when the machine is in sleep mode, from the point of view of the OS and programs, it might as well be off.

EDIT: take note of the other answers which indicate work-arounds using some Windows APIs and tools (which presumably work with the motherboard to provide timed wake-ups).

Overarch answered 18/10, 2010 at 14:56 Comment(0)
M
3

I know the client component of WHS allows your PC to wake itself to perform a client side backup. You can actually specify the option of waking the PC from sleep to perform the backup which is controlled via the actual WHS. How they accomplish this task is not via Java and I'm sure they have varying hooks into the OS, since in Sleep mode there is actually power still being supplied. Here is an article that talks about detecting the move to standby and preventing it, within Java/C++ and may hold value for what you are trying to accomplish in a different manner. In addition you could make use of WOL to wake the PC remotely.

Miscarriage answered 18/10, 2010 at 15:6 Comment(0)
B
1

If your machine's asleep, then everything is suspended. Including any custom apps you might want to run.

Barri answered 18/10, 2010 at 15:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.