This content has been marked as final. Show 3 replies
for in-memory, thread-safe queueing, use a BlockingQueue.1 person found this helpful
1 person found this helpful
I cannot seem to use ObjectInputStream and ObjectOutputStream with them.That does work, but there are gotchas:
1. They block more readily than sockets because the internal buffer is only 4k instead of at least 8k at both ends of a socket, more like 90k in total if there are no Windows platforms involved.
2. You must create the pipes themselves first, connected together; then start the reading thread; then construct the ObjectOutputStream around the PipedOutputStream; the reading thread must construct the ObjectInputStream around the PipedInputStream in its run method. Otherwise things will jam or fail in various ways due to the object stream header, and the requirement to have the pipes connected to each other, and a read thread in existence when you write.
Thank you, BlockingQueue is exactly what I was looking for. I had found a example of using the Pipe and Objects but now I know why it was written that way. I could not get it to work because I shortened it and did not setup the pipe first. Thanks!! - Jeremy