Code:
main function{
Thread t =new Thread(){
public void run(){
Process p= Runtime.getRuntime().exec(my_CMD);
}
};
t.start();
//Now here, I want to kill(or destroy) the process p.
How can I do this in Java? If I make it as a class field as in
main function{
Process p;
Thread t =new Thread(){
public void run(){
p= Runtime.getRuntime().exec(my_CMD);
}
};
t.start();
//Now here, I want to kill(or destroy) the process p.
Since it is in a thread, it asks me to make the Process P as final
. If I make that final
, I cant assign value here. p= Runtime.getRuntime().exec(my_CMD);
. plz help.