You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Darryl Miles <da...@netbauds.net> on 2013/07/11 13:21:36 UTC

Re: WebSockets Thread Safety question

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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org