public void acceptConnection(BtConnection connection, boolean server) { mutex.writeLock().lock(); try { if (!hasConnection(connection.getRemoteDevice().getBluetoothAddress()) && connections.size() < 2) { ConnectionHandler handler = new ConnectionHandler(connection); connections.put(handler.getBtAddress(), handler); handler.start(); routingTable.add(localDevice.getBluetoothAddress(), handler.getBtAddress()); } else { connection.close(); } } catch (IOException e) { Log("SynCore.acceptConnection", e.getMessage()); } finally { mutex.writeLock().unlock(); } }