public void addDispatchedMessage(ThreadIdentifier tid, long sequenceId) {
    Long lastSequenceNumber = sequenceId;
    boolean wasEmpty;
    Long oldvalue;
    Map internalMap;
    while (true) {
      internalMap = threadIdToSeqId.map;
      synchronized (internalMap) {
        if (internalMap != threadIdToSeqId.map) {
        } else {
          wasEmpty = internalMap.isEmpty();
          oldvalue = (Long) internalMap.put(tid, lastSequenceNumber);
          if (ackedEvents != null) {
            ackedEvents.put(tid, lastSequenceNumber);
          }
          if (oldvalue != null && oldvalue.compareTo(lastSequenceNumber) > 0) {
            internalMap.put(tid, oldvalue);
            if (ackedEvents != null) {
              ackedEvents.put(tid, oldvalue);
            }
          }
          break;
        }
      }
    }
    if (wasEmpty) {
      // Asif: If the wasEmpty flag is true this would mean that the
      // dispatchedMessagesMap should not contain the threadIdToSeqID
      // Map as it should have been removed by QRM thread
      // Also because unless the map is actually put by the thread experiencing
      // the wasEmpty flag true, the QRM thread cannot find it & hence cannot
      // toggle it.
      // Thus a condition where the internalMap being put by the dispatcher
      // thread is stale ( that is already replaced by QRM thread ) cannot
      // arise. Once the dispatcher thread has put the Map , then the
      // QRM thread may empty it & replace it with a new Map
      Map<String, MapWrapper> tempDispatchedMessagesMap = dispatchedMessagesMap;
      if (tempDispatchedMessagesMap != null) {
        MapWrapper old = tempDispatchedMessagesMap.putIfAbsent(regionName,
            threadIdToSeqId);
        if (isUsedByTest) {
          testMarkerMessageReceived = true;
          if (logger.isDebugEnabled()) {
            logger.debug("testIsAckReceived: {}", testMarkerMessageReceived);
          }
        }
        Assert.assertTrue(old == null);
      }
    }
  }
It adds the entry to a static data structure dispatchedMessagesMap which is periodically
operated upon by the QRM thread.

@param tid - the ThreadIdentifier object for this event
@param sequenceId - the sequence id for this event
geode-core/src/main/java/org/apache/geode/internal/cache/ha/HARegionQueue.java