Code example for ScheduledExecutorService

Methods: schedule

0
        } 
    } 
 
    private void scheduleFlush() { 
        removeAnyScheduledFlush(); 
        mFlushFuture = mExecutor.schedule(mFlushCallable, FLUSH_DELAY_IN_MS, TimeUnit.MILLISECONDS);
    } 
 
    /** 
     * Queues up {@code logUnit} to be published in the background. 
     * 
     * @param logUnit the {@link LogUnit} to be published 
     * @param canIncludePrivateData whether private data in the LogUnit should be included 
     */ 
    public synchronized void publish(final LogUnit logUnit, final boolean canIncludePrivateData) {
        try { 
            mExecutor.submit(new Callable<Object>() {
                @Override 
                public Object call() throws Exception {
                    logUnit.publishTo(ResearchLog.this, canIncludePrivateData);
                    scheduleFlush();