long () { NextPair nextPair = localCounter.get(); if (nextPair == null || nextPair.nextId == nextPair.limit) { long start = nextChunkStart.getAndAdd(CHUNK_SIZE); nextPair = new NextPair(start, start + CHUNK_SIZE); localCounter.set(nextPair); } long result = nextPair.nextId; nextPair.nextId++; return result; }