void () { boolean b = invokeLaterScheduled.compareAndSet(true, false); assert b; if (stopped || myShutUpCondition.getAsBoolean()) { stop(); return; } long start = System.currentTimeMillis(); int processed = 0; while (true) { if (processNext()) { processed++; } else { break; } long finish = System.currentTimeMillis(); if (myMaxUnitOfWorkThresholdMs != -1 && finish - start > myMaxUnitOfWorkThresholdMs) break; } if (!isEmpty()) { scheduleUpdate(); } }