0

Say I have one Java program running on machine A, now I want to interrupt it, save its context and resume its execution on machine B. Is it possible to do that? How?

Shen Li
  • 411
  • 3
  • 14

2 Answers2

1

no, there's no good way to "freeze" a process and "revive" it on a separate machine, the process might be holding all sorts of state (open files/sockets etc) that you cant move with it.

if its an application youre writing its better to make it clusterable and then just start up another node on the target machine, wait for those 2 nodes to sync and shut fown your original node.

if its not an application youre writing or the above is too much, run your application inside a VM and use the VM's capabilities to migrate the entire VM with the running app in it (so, just use vmotion).

radai
  • 23,949
  • 10
  • 71
  • 115
1

You might try something like this - the point at which you interrupt your program, just serialize all its properties / objects and also set a flag to indicate the point from where it can re-start executing. Now copy the serialized stuff to the other machine and start the program. Your code should be able to handle the conditions to correctly store (serialize) the state of your program and continue from that point whenever the class is started on another machine.

Sudhanshu Umalkar
  • 4,174
  • 1
  • 23
  • 33