/java/util>javap Collections | grep synchronized public static java.util.Collection synchronizedCollection(java.util.Collecti on); static java.util.Collection synchronizedCollection(java.util.Collection, jav a.lang.Object); public static java.util.Set synchronizedSet(java.util.Set); static java.util.Set synchronizedSet(java.util.Set, java.lang.Object); public static java.util.SortedSet synchronizedSortedSet(java.util.SortedSet) ; public static java.util.List synchronizedList(java.util.List); static java.util.List synchronizedList(java.util.List, java.lang.Object); public static java.util.Map synchronizedMap(java.util.Map); public static java.util.SortedMap synchronizedSortedMap(java.util.SortedMap) ;
use java.util.Collections.synchronizedList Martin ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > From: ch...@derham.me.uk > Date: Mon, 3 Jun 2013 07:42:01 -0300 > Subject: Re: WebSockets Thread Safety question > To: users@tomcat.apache.org > > > When I use the syntax from the samples in the onTextMessage() method, I get > > ConcurrentModificationException if I have more than one client sending data > > to the server at the same time: > > > > for(MyMessageInbound mmib: mmiList){ > > CharBuffer buffer = CharBuffer.wrap(cb); > > mmib.myoutbound.writeTextMessage(buffer); > > mmib.myoutbound.flush(); > > } > > > > > > Changing it to the following works fine: > > > > for(int i = 0; i < mmib.size(); i++) { > > MyMessageInbound mmib = mmiList.get(i); > > CharBuffer buffer = CharBuffer.wrap(cb); > > mmib.myoutbound.writeTextMessage(buffer); > > mmib.myoutbound.flush(); > > } > > > > However, this approach is not as efficient as to use an Iterator, unless I > > clone the mmiList Collection to iterate over it... > > Can you explain where is the in-efficiency? > > Thanks > > Chris > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org >