Example usage for com.google.common.util.concurrent ListeningScheduledExecutorService execute

List of usage examples for com.google.common.util.concurrent ListeningScheduledExecutorService execute

Introduction

In this page you can find the example usage for com.google.common.util.concurrent ListeningScheduledExecutorService execute.

Prototype

void execute(Runnable command);

Source Link

Document

Executes the given command at some time in the future.

Usage

From source file:org.neoscoinj.core.PeerGroup.java

protected ListeningScheduledExecutorService createPrivateExecutor() {
    ListeningScheduledExecutorService result = MoreExecutors.listeningDecorator(
            new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory("PeerGroup Thread")));
    // Hack: jam the executor so jobs just queue up until the user calls start() on us. For example, adding a wallet
    // results in a bloom filter recalc being queued, but we don't want to do that until we're actually started.
    result.execute(new Runnable() {
        @Override/*from   w  ww .j  av a 2 s.  c  o m*/
        public void run() {
            Uninterruptibles.awaitUninterruptibly(executorStartupLatch);
        }
    });
    return result;
}

From source file:org.bitcoinj_extra.core.PeerGroup.java

protected ListeningScheduledExecutorService createPrivateExecutor() {
    ListeningScheduledExecutorService result = MoreExecutors.listeningDecorator(
            new ScheduledThreadPoolExecutor(1, new ContextPropagatingThreadFactory("PeerGroup Thread")));
    // Hack: jam the executor so jobs just queue up until the user calls start() on us. For example, adding a wallet
    // results in a bloom filter recalc being queued, but we don't want to do that until we're actually started.
    result.execute(new Runnable() {
        @Override//from ww  w  .j av a2 s  .c o  m
        public void run() {
            Uninterruptibles.awaitUninterruptibly(executorStartupLatch);
        }
    });
    return result;
}