tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darryl Miles <>
Subject Re: WebSockets Thread Safety question
Date Thu, 11 Jul 2013 11:21:36 GMT
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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message