diff rep/Session.java @ 275:3be92eb54b1c

*** empty log message ***
author kono
date Wed, 24 Sep 2008 17:31:57 +0900
parents ad487e63e3c8
children a549bd4dadb8
line wrap: on
line diff
--- a/rep/Session.java	Wed Sep 24 15:49:09 2008 +0900
+++ b/rep/Session.java	Wed Sep 24 17:31:57 2008 +0900
@@ -1,8 +1,11 @@
 package rep;
 
+import java.nio.channels.SelectionKey;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
+import rep.channel.REPSelectionKey;
 import rep.channel.REPSocketChannel;
 
 public class Session {
@@ -54,9 +57,11 @@
 	
 	public boolean deleteEditor(REPSocketChannel<REPCommand> channel) {
 		boolean flag = false;
-		for(Editor editor : editorList){
-			if(editor.getChannel() == channel) {
-				editorList.remove(editor);
+
+	    for (Iterator<Editor> it = editorList.iterator();it.hasNext(); ) {
+	        Editor e = it.next();
+			if (e.getChannel()==channel) {
+				it.remove(); // to avoid concurrent modification
 				flag = true;
 			}
 		}