当 Windows 处于睡眠模式时,计划的 Java 应用程序会运行吗?

发布于 2024-09-28 03:25:05 字数 233 浏览 10 评论 0原文

如果我启动一个 Java 应用程序,它会启动并执行一些工作,然后进入线程睡眠一小时,然后在一小时后醒来并执行更多工作...

但是我的电脑运行的是 Win7,在不活动 15 分钟后,它将进入睡眠模式,所以我的问题是:从我启动 Java 应用程序一小时后,如果我不触摸 PC,并且它进入睡眠模式,我的 Java 应用程序是否仍然能够唤醒并执行其工作,如果是这样的话,Win7电脑唤醒后屏幕会再次打开吗[因为在Win7睡眠模式下屏幕会关闭]?

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 ] ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦回旧景 2024-10-05 03:25:05

普通的 Thread.sleep() 不会将计算机从睡眠模式中唤醒。

但是,当向Windows任务计划程序注册任务时,您可以选择“唤醒计算机以运行此任务”。当进入睡眠模式时,Windows会告诉主板下一次注册的唤醒任务的时间。

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.

才能让你更想念 2024-10-05 03:25:05

如果 Windows 不运行,它怎么可能运行?主板支持的自动唤醒可能有一些技巧,但当机器处于睡眠模式时,从操作系统和程序的角度来看,它可能会关闭。

编辑:记下其他答案,这些答案指出了使用某些 Windows API 和工具的解决方法(可能与主板一起提供定时唤醒)。

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).

水溶 2024-10-05 03:25:05

我知道 WHS 的客户端组件允许您的电脑自行唤醒执行客户端备份。您实际上可以指定将电脑从睡眠状态唤醒以执行备份的选项,该备份是通过实际的 WHS。他们如何完成这项任务不是通过 Java,而且我确信他们对操作系统有不同的挂钩,因为在睡眠模式下实际上仍在供电。这是一篇文章,讨论了检测移动到在 Java/C++ 中备用并防止它,并且可能对您尝试以不同方式完成的任务有价值。此外,您还可以使用 WOL 远程唤醒电脑。

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.

思念绕指尖 2024-10-05 03:25:05

如果您的机器处于睡眠状态,那么一切都会暂停。包括您可能想要运行的任何自定义应用程序。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文