Dear users,

i am trying to develop a front end to a linux based program. i am using swing (j2sdk 1.4.2) for this purpose. the gui part of it works fine and i could manage to get the program running on my linux system using getRuntime().exec(). And I would like to pipe the output back to the gui window and display it in a non-editable textarea. The program writes output both to the stdout and stderr streams. i could read both the streams using the getOutputStream() and getErrorStream() methods. and i have no problems getting it back to the gui window. but my problem is synchronization. the program writes to these two output streams, alternately. so, if i read one of the streams completely and go to the other, the output i would endup displaying in my gui window would be out of order, as compared to what i would read, had i run the program on the command line (independent of the gui window). so, is there any way of threading, so that i can read from the standard output streams of the program, in such a way that the output in my gui window conforms with the order it follows on the command line? Precisely, i would like to know how to detect the beginning of a stream, and how to react to minor pauses in the streams.

any help would be greatly appreciated.
thanks in anticipation.