Re: How do you _really_ get a PrintStream to flush all the time?



"Rob McDonald" <robm@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:dhhdts$pik$1@xxxxxxxxxxxxxxxxxxxxxx
>
> Maybe I didn't pour enough of my sorrows into it (I have lots of them, it
> could take a while), but I honestly don't have the slightest idea how this
> is supposed to help me.

You're not alone; based on your description of the problem, it would
seem to me that the source of all this confusion is your use of threads, and
has nothing to do with FileIO.

The situation you've got is a classic problem in multithreading known as
"producer/consumer". You should have a buffer of text (which is NOT the
JTextArea). You've got a producer which will put text into the buffer. You
should have a consumer which eats text out of the buffer and spits it back
out into the JTextArea. You want the producer to not produce text so fast
that it fills up the buffer and starts overwriting itself.

Try this tutorial:
http://java.sun.com/docs/books/tutorial/essential/threads/synchronization.html

- Oliver


.



Relevant Pages