code: private void scheduleFlushTask()
     {
        // cancel task
        if (flushTask != null)
        {
           flushTask.cancel();
        }
        // clear canceled tasks
        FLUSH_TIMER.purge();
        // new flush task, cause canceled can't be re-used
        flushTask = new TimerTask()
        {
           @Override
           public void run()
           {
              // check if volatile index should be flushed
              checkFlush();
           }
        };
        FLUSH_TIMER.schedule(flushTask, 0, 1000);
        lastFlushTime = System.currentTimeMillis();
        lastFileSystemFlushTime = System.currentTimeMillis();
     }
docs: Cancel flush task and add new one