Hi all,
I was told that any data going out over an output stream (i'm using tcp/ip in my case) could block. In that case, I would not want to halt the application by having to wait for data to go out.
I need a model of how to do this.
I need to send message objects over this stream.
I am thinking I need a blocking queue that contains these message objects. The thread's run() method would grab any message objects that are available and send them, while true.
My questions are 1) Is there a better way to do this than a while true loop? Perhaps in the while true loop if there are no messages to send, I can tell the thread to yield/sleep.
2) Is there a better model to use? I am concerned that if I have a while(true) in my code that it will eat processor cycles waiting for messages.
Please, someone who has experience with this, let me know if there's a better way about this.
Thanks, jbu