javahibernation

Pausing program until next startup


I have a program which bruteforces an AES256 encryption, how would I pause the program when the computer goes into shutdown/or reboot and continue at the same point until the next boot of the system?

A sort of hibernate of the program.


Solution

  • You asked three things here.

    1- How can I check when the OS goes reboot/shutdown

    Solution: You can make an empty invisible window, and add WindowListener to it. It will receive windowClosing event on windows.

    You can find an example HERE

    2- How can I save the state of my BruteForce process and pause to start again when system goes up.

    Solution: Here is easy, you must serialize. These will save the state of your class/classes to deserialize when system goes UP again. You can study HERE

    3- How know when startup the programm again when OS goes UP?

    Solution: You can put your program in initialization process of your OS. When it starts, you check if there is anything to deserialize and do it, restoring the process of the BruteForce.