Skip to content

Commit

Permalink
用ConcurrentLinkedQueue来保存session实例,避免并发修改异常
Browse files Browse the repository at this point in the history
  • Loading branch information
codefollower committed Mar 23, 2016
1 parent 620de51 commit 995444a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lealone-net/src/main/java/org/lealone/net/CommandHandler.java
Expand Up @@ -71,20 +71,16 @@ public static void removeConnection(AsyncConnection c) {
c.close();
}

private final LinkedList<Integer> sessions = new LinkedList<>();
private final ConcurrentLinkedQueue<Integer> sessions = new ConcurrentLinkedQueue<>();
private final Semaphore haveWork = new Semaphore(1);
private boolean stop;

void addSessionId(Integer sessionId) {
synchronized (sessions) {
sessions.add(sessionId);
}
sessions.add(sessionId);
}

void removeSessionId(Integer sessionId) {
synchronized (sessions) {
sessions.remove(sessionId);
}
sessions.remove(sessionId);
}

public CommandHandler(int id) {
Expand Down

0 comments on commit 995444a

Please sign in to comment.