private void flushWrites() {
      if (writeBatch != null && !writeBatch.isEmpty()) {
        try {
          Queue<T> oldWriteBatch = writeBatch;
          writeBatch = null;
          writeBatchRef.set(null);
          // blocks if full
          if (!itemQueue.offer(oldWriteBatch)) {
            long start = System.nanoTime();
            itemQueue.put(oldWriteBatch);
            enqueueBlockTimeNanos.incBy(System.nanoTime() - start);
          }
        } catch (InterruptedException ex) {
          Thread.currentThread().interrupt();
          throwFatalException(ex);
        }
      }
    }
Caches thread-local values so that a single thread can accept new items without having to do thread-local lookups.
planetiler-core/src/main/java/com/onthegomap/planetiler/worker/WorkQueue.java