Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D5B2BC2EA for ; Mon, 3 Jun 2013 10:42:51 +0000 (UTC) Received: (qmail 86263 invoked by uid 500); 3 Jun 2013 10:42:48 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 86215 invoked by uid 500); 3 Jun 2013 10:42:48 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 86202 invoked by uid 99); 3 Jun 2013 10:42:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Jun 2013 10:42:47 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cjderham@gmail.com designates 209.85.223.169 as permitted sender) Received: from [209.85.223.169] (HELO mail-ie0-f169.google.com) (209.85.223.169) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Jun 2013 10:42:42 +0000 Received: by mail-ie0-f169.google.com with SMTP id 10so8258670ied.28 for ; Mon, 03 Jun 2013 03:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=rG6xCJ1BbBdXifIXo8snBGyl4X5w3/17zbskZ/DRTZc=; b=GJrKigcT8Ut65u19RalyOO8gKbNFaQJTmYUlLAfW33Jr+F7OHufTKY/CR/43sIbBBx fCSKKRt++0HatjXszY6LS4IRwWl0zAqkb6SdUJSESrvtUudWxqrOpQwXbZM/sCT3fXCk K5Y40Vac5P6/hcxoN1tDcE6bl3UCO0Rru3W5fkso0oAqw6M/wDpr/hWrt8hg4r+d7NIu Q067uQMiXUXXl9W3ow62wX0YbQMABoVB7p8V9Rwx1hSCbFemhec3HSnON/f38jy6UpCI kqf/PQ/eGn0MDhXKOaNpiEH1wer9QAEEs5C38lFuUjM+WI6Ryy2CSz8xEErX8RjvE7yx C4Pg== X-Received: by 10.50.44.111 with SMTP id d15mr7605586igm.65.1370256141956; Mon, 03 Jun 2013 03:42:21 -0700 (PDT) MIME-Version: 1.0 Reply-To: chris@derham.me.uk Sender: cjderham@gmail.com Received: by 10.64.107.39 with HTTP; Mon, 3 Jun 2013 03:42:01 -0700 (PDT) In-Reply-To: References: From: chris derham Date: Mon, 3 Jun 2013 07:42:01 -0300 X-Google-Sender-Auth: rDQNpnJAR9xMWGUeN809XFHUb0M Message-ID: Subject: Re: WebSockets Thread Safety question To: Tomcat Users List Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on 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-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org