public synchronized void setConnected(boolean flag) {
        ConnectedLock.lock();
        Connected = flag;
        ConnectedDecided = true;
        ConnectedCond.signalAll();
        ConnectedLock.unlock();
    }