Download Java.lang.Process.destroy() Method Example

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
JAVA.LANG.PROCESS.DESTROY METHOD
http://www.tutorialspoint.com/java/lang/process_destroy.htm
Copyright © tutorialspoint.com
Description
The java.lang.Process.destroy method kills the subprocess. The subprocess represented by this
Process object is forcibly terminated.
Declaration
Following is the declaration for java.lang.Process.destroy method
public abstract void destroy()
Parameters
NA
Return Value
This method does not return a value.
Exception
NA
Example
The following example shows the usage of lang.Process.destroy method.
package com.tutorialspoint;
public class ProcessDemo {
public static void main(String[] args) {
try {
// create a new process
System.out.println("Creating Process...");
Process p = Runtime.getRuntime().exec("notepad.exe");
// wait 10 seconds
System.out.println("Waiting...");
Thread.sleep(10000);
// kill the process
p.destroy();
System.out.println("Process destroyed.");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Let us compile and run the above program, this will produce the following result:
Creating Process...
Waiting...
Process destroyed.
Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js
Related documents