tags:

views:

152

answers:

2

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?

A: 

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.

stacker
hi...can u give me any example of this JVM Tool interface.....
kosal
A: 

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.

Elijah
Hi...everyone.....i want to spawn a java process from the java...like Runtime.getRuntime().exec("java <para>"); ...like this.....but wat problem is happening is,excution of this exec() command take place wen the jvm shut down.....i dont want to shut down the jvm...but stil want to run the exec() process.....this is my problem....
kosal