public synchronized void signalReceived(boolean flag) {
        ReceivedLock.lock();
        if (flag == true) {
            try {
                DataInputStream dis = new DataInputStream(RIS);
                ResultCode = dis.readInt();
                Received = true;
            } catch (IOException ex) {
                ex.printStackTrace();
                Received = false;
            }
        } else {
            Received = false;
        }
        ReceivedDecided = true;
        ReceivedCond.signalAll();
        ReceivedLock.unlock();
    }