[英]What happens to a Java program when you turn the power off?
What happens within a Java application running locally on a PC when the power is switched off?(Plug pulled from wall).当电源关闭时,在 PC 上本地运行的 Java 应用程序会发生什么?(从墙上拔下插头)。
Does Java have a way of handling an event like this or is it simply wiped from memory as soon as the power is killed? Java 有没有办法处理这样的事件,还是只是在断电后立即从内存中擦除?
Edit: To be a bit more clear, I'm wondering if Java as any way of safely exiting an application in the last moments of an unexpected shutdown.编辑:更清楚一点,我想知道 Java 是否可以作为在意外关闭的最后时刻安全退出应用程序的任何方式。
Java programs (like all programs) require a CPU and memory to operate instructions. Java 程序(与所有程序一样)需要 CPU 和内存来操作指令。 Both elements are complex electrical circuits, they cannot work without electricity.
这两个元件都是复杂的电路,没有电就不能工作。
The only thing you can do to persist the state of your application, is to write information regarding that state to disc.要保持应用程序的状态,您唯一可以做的就是将有关该状态的信息写入磁盘。 The Google File System uses this method to ensure not too much information is lost if one of their (usually inexpensive machines) goes down.
谷歌文件系统使用这种方法来确保在他们的一台(通常是便宜的机器)出现故障时不会丢失太多信息。
Short of this.少了这个。 No there is no way Java can handle a power out.
不,Java 无法处理断电。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.