Java 中的进程如何判断已经终止?
Processprocess=Runtime.getRuntime().exec("exe/Debug/test.exe");如何判断process已经终止呢?满意加分~...
Process process = Runtime.getRuntime().exec ("exe/Debug/test.exe");
如何判断process 已经终止呢?满意加分~
返回是int啊,我想监控程序终止怎么办呢?只要判断一下就行了! 展开
如何判断process 已经终止呢?满意加分~
返回是int啊,我想监控程序终止怎么办呢?只要判断一下就行了! 展开
1个回答
展开全部
Process类提供的函数很少,找了一下,能跟判断终止有关的函数只有一个:
exitValue()
public abstract int exitValue()Returns the exit value for the subprocess.
Returns:
the exit value of the subprocess represented by this Process object. by convention, the value 0 indicates normal termination.
Throws:
IllegalThreadStateException - if the subprocess represented by this Process object has not yet terminated.
通过这个函数可得到Process的终止方式。如果未终止,抛出异常。
捕获这个异常就行了。
exitValue()
public abstract int exitValue()Returns the exit value for the subprocess.
Returns:
the exit value of the subprocess represented by this Process object. by convention, the value 0 indicates normal termination.
Throws:
IllegalThreadStateException - if the subprocess represented by this Process object has not yet terminated.
通过这个函数可得到Process的终止方式。如果未终止,抛出异常。
捕获这个异常就行了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询