Code example for ScheduledExecutorService

Methods: schedule

    private void scheduleFlush() { 
        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>() {
                public Object call() throws Exception {
                    logUnit.publishTo(ResearchLog.this, canIncludePrivateData);
Experience pair programming with AI  Get Codota for Java