From 0b1f9383ceef948a22ae163c0524ab9fa212183b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 21 Jun 2011 03:31:43 +0200 Subject: Fix NullPointerException on disconnect git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@534 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/control/network/ConnectionControl.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/jrummikub/control') diff --git a/src/jrummikub/control/network/ConnectionControl.java b/src/jrummikub/control/network/ConnectionControl.java index 2d8ff60..897d0f5 100644 --- a/src/jrummikub/control/network/ConnectionControl.java +++ b/src/jrummikub/control/network/ConnectionControl.java @@ -68,6 +68,12 @@ public class ConnectionControl implements IConnectionControl { private final static String ELEMENT_NAME = "rummikub"; private final static String NAMESPACE = "http://home.universe-factory.net/rummikub/"; + private final static Runnable STOP_ACTION = new Runnable() { + @Override + public void run() { + } + }; + private final LoginData loginData; private volatile Connection connection; private volatile MultiUserChat muc; @@ -120,18 +126,14 @@ public class ConnectionControl implements IConnectionControl { new Thread(new Runnable() { @Override public void run() { - while (true) { - Runnable runner; + Runnable runner = null; + do { try { runner = actionQueue.take(); - if (runner == null) { - return; - } - runner.run(); } catch (InterruptedException e) { } - } + } while (runner != STOP_ACTION); } }).start(); @@ -149,7 +151,7 @@ public class ConnectionControl implements IConnectionControl { connection.disconnect(); connection = null; } - ConnectionControl.this.run(null); + ConnectionControl.this.run(STOP_ACTION); } }); } -- cgit v1.2.3