Home arrow static arrow Java Programming [Archive] - Runtime.exec(): VM creates batch executions???
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Runtime.exec(): VM creates batch executions???
This topic has 1 reply on 1 page.

Posts:3,369
Registered: 24.10.97
Runtime.exec(): VM creates batch executions???  
Jul 30, 2004 3:57 AM



 
I wrote an application that performs a task within a loop. Therefore i setup up a prograssbar in my GUI. during testing, the progressbar showed nice progress by just perforing a Thread.sleep() as the task. Then i replace the Thread.sleep() with the real task that is execution of a system command:

                    Runtime rt = Runtime.getRuntime();                    process = rt.exec(command);                          exitCode = process.waitFor(); //wait until system command returns


and suddenly the progressbar doesn't proceed but pops up at the and of the complete loop. First i thought it is a refresh problem of the progressbar, but after i insertet System.out, these System.outs within the loop also only get printed (all but the very first) at the end of the loop. Toggling between the execution tasks "Thread.sleep" and "Runtime.exec" also toggles "nice progress output" and "output all at the end of the loop".

I wonder why this happens?
 

Posts:3,369
Registered: 24.10.97
Re: Runtime.exec(): VM creates batch executions???  
Jul 30, 2004 4:19 AM (reply 1 of 1)



 
At least, i can workaround this because my system command throwed an IOException. With the correct command, it worked. But the effect still occurs, because I added a System.out in the catch clause and when using the wrong command (that cause the IOException), even those System.outs were printed in a batch way (all at wants) after all tasks finsihed. System.out.flush() didn't make any difference.
 
This topic has 1 reply on 1 page.