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:

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".

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.