Martin Gainty wrote:
use java.util.Collections.synchronizedList

or even better use a ConcurrentLinkedQueue class (with offer()/peek()/poll() APIs), as I suspect you never need to access the middle elements in the ordered list directly, so why carry this extra java.util.List API baggage/bloat in respect of the implementation chosen for efficient concurrency.

You can gain performance from being able to enqueue at one end and dequeue from the other end efficiently and as concurrently as possible.

Useful for handing off data to a shared I/O worker thread but be careful to consider flow control and back pressure where the enqueuing code will be forced to block or generate an error when there are is already too many bytes of data in the queue.

Adding in that kind of requirement makes things more tricky than ConcurrentLinkedQueue by itself can provide.


Darryl


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to