-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Chris,
On 6/3/13 6:42 AM, chris derham wrote: >> 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? +1 -- the compiler generates pretty much identical bytecode in either case. I suppose having less actual code is a nice thing; I tend to agree with that sentiment. What I'd like to know is why there is a difference /at all/ in the two code samples shown above. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJRrPPTAAoJEBzwKT+lPKRYkEsP/AiTKqT+ZM2uH9tmi2Ktcm2F yjtSNQHW/iCp3aGZH+GsQf82FulpZh81j/fRAKJNf/5EWX8LQEdXZt7+r3OvlVs/ t0gF0CWgmyyF0blHu0L8/0uE4n1j+9fNpNdSKveQdfnXNoJ+3OAUd9FtkJfRz3cv /VnIbztxmTdVtpFXRLCNLHSDd13zHKK8+KW/jE7W0aoQlxDFcnozdOniDZgvoIgv r5YwgeZTdNLDf703DfspjjWkqc4rp1LVKjBAUcIbIIvqXMlNiXWrTWrMXHatcOQY 6pNJxmWXB05IOCzK39U2VX7v9vkbrh/8tpbNgM15MRoJlwm2sGwHHRCNWrgvS9Pj YNVWaz/gED4GKVzs2ky+wYu1OQwVTOW3IJPktIORuf8w6RdPC9tHbzE7JdVBGabj 2vJ6t6xqHiEAw0deQPUvVZqvOWRELR+Zs1+++ESPswnl2Dn50QobN1JRVqmEEtVn ZTxQE8onwCxv92yv4R5Yy/NtrHD8g02kMm12YqlFlT73fSGN+GR+uq0fgN8nYv1A QIbVpZ4essX7LrhQ8HvRaiFX0RjwLiUHVlPDOagnHO4KFp+ttQK6DL19444Jv9Y/ gXCe1eFEexzF2MBdeNV+j3HjQCmCVJkGiCGoEXAwEKli5orNl8+WNts7TybAFIgg n2HAWhN0WaU+/G8pEc3r =DGKf -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org