public void register() throws UCESipException, InterruptedException { stateLock.lock(); try { currentServerState.startRegister(); while (true) { if (currentServerState.getCurrentState() == ServerStates.Registered) { break; } if (currentServerState.getCurrentState() == ServerStates.Error) { // check for asynchronous error throw ((ErrorServerState) currentServerState).getError(); } stateChangeCondition.await(); } long tp = sipSettings.getServerCallMapCleanupPeriodMillis(); callMapCleanupTimer.scheduleAtFixedRate(callMapCleanupTask, tp, tp); } catch (InterruptedException e) { throw e; } finally { stateLock.unlock(); } }