hi all,
I want to stop JVM for some time after some minutes JVM should run its execution from that point. Is that possible in Java?
Or I want to run my some part of code in diffrent JVM instance?
hi all,
I want to stop JVM for some time after some minutes JVM should run its execution from that point. Is that possible in Java?
Or I want to run my some part of code in diffrent JVM instance?
For whatever you want to do this. You could try to suspend all threads for a while and resume after a delay using JVM Tool Interface This may not be availabe on all JVMs thus you should query capabilities first.
To start something in a new JVM instance u can
try {
Runtime.getRuntime().exec("java <another class to run in the new JVM instance>")
}
catch(Exception e) {
// handle the exception
}
then save its state and resume at some point providing latest state. Also to programmatically "pause" the execution, you should start the class u want to pause at some point in a separate thread (it doesn't have to be a process (a new JVM instance) to be paused) and put it to sleep for some time. Resource-wise the approach with threads is better, but keep in mind that a process has limited amount of memory available (and the multiple threads consume a lot of it) so u'll probably need to increase that amount.