@Override
    public void put(long key, long value) {
      long offset = key << 3;
      long segment = offset >>> segmentBits;
      // this thread is moving onto the next segment, so coordinate with other threads to allocate
      // a new buffer if necessary while limiting maximum number of segments held in-memory
      if (segment > lastSegment) {
        if (segment >= Integer.MAX_VALUE) {
          throw new IllegalArgumentException("Segment " + segment + " > Integer.MAX_VALUE");
        }
        SegmentActions actions = advanceTo((int) segment);
        // iterate through the tail-end and free up chunks that aren't needed anymore
        actions.perform();

        // wait on adding a new buffer to head until the number of pending buffers is small enough
        buffer = actions.awaitBuffer();
        lastSegment = segment;
        segmentOffset = segment << segmentBits;
      }
      buffer.putLong((int) (offset - segmentOffset), value);
    }
Handle for a single worker thread to write values in parallel with other workers.
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/ArrayLongLongMapMmap.java