/** {@inheritDoc} */ @Override public void run() { Thread t = Thread.currentThread(); // We clear interrupted flag here in order to let the final flush proceed normally with IO operations. while (!Thread.interrupted()) { flushLock.lock(); try { while (cnt.get() < batchSize && !t.isInterrupted()) { try { U.await(flushCond, 1000L, TimeUnit.MILLISECONDS); } catch (GridInterruptedException ignore) { t.interrupt(); break; } } } finally { flushLock.unlock(); } if (!t.isInterrupted()) flush(); } // Flush remaining entries. flush(); }