void (Runnable runnable) { if (Boolean.TRUE.equals(isInBatchUpdate.get())) { runnable.run(); } else { isInBatchUpdate.set(true); try { runnable.run(); } finally { isInBatchUpdate.remove(); } if (!batchItems.isEmpty()) { flushBatch(); } } }