Save and load a (Java) program's state
Suppose you're short on time and you're looking for a program with certain features, and you find one, except it lacks one feature - it cannot save and load its state. Is it possible to achieve this on OS level, or with another program, that can take the whole thing, write it to a file, and then at a later time, load it back into memory? How?
Specifically for me, this is about a Java pr开发者_Python百科ogram, but any more information on this topic is welcome.
One (heavy and easy) solution could be to use VirtualPC and install the program on a virtual OS.
Check these library's:-
- Brakes
- ACTC(Asynchronous Transfer of Control Threading) [Article]
- Apache JavaFlow
You want to do something like the Hibernate function of Windows right?
This will be extremely difficult to implement in Java as you will also have to write the state of the JavaVM. If you had open files when you closed the program end so on.
I think the best you can do is writing the objects you need to recover to disk using Java serialization.
Have a look at the CRIU project at https://criu.org/Main_Page
It offers exactly this possibility within linux systems. Docker integrates it and offers a docker checkpoint command, which if you run your program in a container, will allow you to do this on any OS.
精彩评论