calling external os command via exec interupts windows that should be drawn

I'm calling the following ...

1.doc.insertString(doc.getLength(), string, doc.getStyle(t));

2.System.out.println(string);

3.Process p = Runtime.getRuntime().exec("/whatever.sh");

4.int i = p.waitFor();

5.if(i == 0) etc ....

the problem is that the #3 seems to be executing before steps #1 and #2 ... or at least the screen is not painted until #3 completes. Now I know I can do p.notify(); but then I don't get a return value from the os command I'm calling and I need it.

I hope someone can help me out with this, I'm still new to java programming.

[602 byte] By [_nokesca] at [2007-10-3 8:52:28]
# 1
?
_nokesca at 2007-7-15 4:02:10 > top of Java-index,Desktop,Runtime Environment...
# 2
no replies? ... does anyone have any theories? I think I was pretty clear in my problem ... maybe this forum just sucks ....
_nokesca at 2007-7-15 4:02:10 > top of Java-index,Desktop,Runtime Environment...