@Override
  public Iterator iterator() {
    if (hasLimitIterator) {
      // Asif: Return a new LimitIterator in the block so that
      // the current Limit does not get changed by a remove
      // operation of another thread. The current limit is
      // set in the limit iterator. So the setting of the current limit
      // & creation of iterator should be atomic .If any subsequent
      // modifcation in limit occurs, the iterator will itself fail.
      // Similarly a remove called by a iterator should decrease the
      // current limit and underlying itr.remove atomically
      synchronized (limitLock) {
        return new LimitBagIterator();
      }
    } else {
      return new BagIterator();
    }
  }
Return an iterator over the elements in this collection. Duplicates will show up the number of
times it has occurrences.
geode-core/src/main/java/org/apache/geode/cache/query/internal/Bag.java