简体   繁体   中英

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

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?

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 programs (like all programs) require a CPU and memory to operate instructions. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM