由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - How to timeout a process
相关主题
[转载] Re: 觉得自己很笨how to multicast objects to clients in java?
性能评价要恰当GC finalize()一问
一道java面试题 (转载)Any good project documentation tools (free?)
java source code analyzing tool巨量数据读取问题求助
help: cannot generate index.html using javadocdtd question
Mini Javadoc Howto -- Re: help: cannot generate index.html using javadoceclipse help
JDK Source?how to integrate java api doc with eclip
How to append something on a file?Re: how to integrate java api doc with e
相关话题的讨论汇总
话题: process话题: timeout话题: what话题: after话题: do
进入Java版参与讨论
1 (共1页)
t**i
发帖数: 9
1
I have a process p = Runtime.getRuntime().exec("some programe). After a
timeout(say t), I need to stop this process if it haven't finish running.
What's the nice way to do that?
Thanks!
g*******e
发帖数: 14
2
check javadoc. I believe it must be there.

【在 t**i 的大作中提到】
: I have a process p = Runtime.getRuntime().exec("some programe). After a
: timeout(say t), I need to stop this process if it haven't finish running.
: What's the nice way to do that?
: Thanks!

f*****g
发帖数: 31
3

No way from Java. But you can call native function/command to halt
your process.

【在 t**i 的大作中提到】
: I have a process p = Runtime.getRuntime().exec("some programe). After a
: timeout(say t), I need to stop this process if it haven't finish running.
: What's the nice way to do that?
: Thanks!

t**i
发帖数: 9
4
Thanks!
Now I found out I can't tell if the process's status after t. If I do
p.exitValue(), it throws IllegalThreadException. If I do p.waitFor(), it
ignores my timing while loop. What I did in my code is:
while (System.currentTimeMillis() - startTime < t)
{
if (p.waitFor() == 0)
break;
}
Could you advise?
Thanks!

【在 f*****g 的大作中提到】
:
: No way from Java. But you can call native function/command to halt
: your process.

g*******e
发帖数: 14
5
p.destroy()

【在 t**i 的大作中提到】
: Thanks!
: Now I found out I can't tell if the process's status after t. If I do
: p.exitValue(), it throws IllegalThreadException. If I do p.waitFor(), it
: ignores my timing while loop. What I did in my code is:
: while (System.currentTimeMillis() - startTime < t)
: {
: if (p.waitFor() == 0)
: break;
: }
: Could you advise?

1 (共1页)
进入Java版参与讨论
相关主题
Re: how to integrate java api doc with ehelp: cannot generate index.html using javadoc
可以动态生成JTree吗??Mini Javadoc Howto -- Re: help: cannot generate index.html using javadoc
ERROR!java.io.RandomAccessFile.readIntJDK Source?
有没有专门作java document的工具How to append something on a file?
[转载] Re: 觉得自己很笨how to multicast objects to clients in java?
性能评价要恰当GC finalize()一问
一道java面试题 (转载)Any good project documentation tools (free?)
java source code analyzing tool巨量数据读取问题求助
相关话题的讨论汇总
话题: process话题: timeout话题: what话题: after话题: do