K
Kevin
Hello,
I am not sure the way that I use the wairFor is right or not (under
WinXP).
The code looks like:
try
{
// print current time.
Process p = Runtime.getRuntime().exec(a_exe_file);
p.waitFor();
// print current time.
}
.......
a_exe_file is a C++ Win32 program which does some calculation.
Here comes the problem:
if I run it as above, I find it does not return (so the second print
time will never happen).
If I remove the p.wairFor() line, of cource, the java process continues
without wait for the a_exe_file to finish (so I see two print time).
I observed something here: from window's task manager, I can see that
in either case, it seems that the a_exe_file will sit in memory after
its work is done -- I can figure out this because a_exe_file is a CPU
eating program. Since it remains in memory even after its work is done,
I guess java will think it is still working so java will wait for
every.
If I run a_exe_file along under windows, it finishs and returns without
any problem. In this way, I am thinking if there is something wrong in
the way I call it from the java code? Why it does not return when
called from Java?
Thanks a lot.
I am not sure the way that I use the wairFor is right or not (under
WinXP).
The code looks like:
try
{
// print current time.
Process p = Runtime.getRuntime().exec(a_exe_file);
p.waitFor();
// print current time.
}
.......
a_exe_file is a C++ Win32 program which does some calculation.
Here comes the problem:
if I run it as above, I find it does not return (so the second print
time will never happen).
If I remove the p.wairFor() line, of cource, the java process continues
without wait for the a_exe_file to finish (so I see two print time).
I observed something here: from window's task manager, I can see that
in either case, it seems that the a_exe_file will sit in memory after
its work is done -- I can figure out this because a_exe_file is a CPU
eating program. Since it remains in memory even after its work is done,
I guess java will think it is still working so java will wait for
every.
If I run a_exe_file along under windows, it finishs and returns without
any problem. In this way, I am thinking if there is something wrong in
the way I call it from the java code? Why it does not return when
called from Java?
Thanks a lot.