Example usage for java.util.concurrent ScheduledThreadPoolExecutor ScheduledThreadPoolExecutor

List of usage examples for java.util.concurrent ScheduledThreadPoolExecutor ScheduledThreadPoolExecutor

Introduction

In this page you can find the example usage for java.util.concurrent ScheduledThreadPoolExecutor ScheduledThreadPoolExecutor.

Prototype

public ScheduledThreadPoolExecutor(int corePoolSize) 

Source Link

Document

Creates a new ScheduledThreadPoolExecutor with the given core pool size.

Usage

From source file:dendroscope.autumn.hybridnumber.ComputeHybridNumber.java

/**
 * constructor//from   www  . j  a  va 2  s .  c o  m
 *
 * @param progressListener
 */
ComputeHybridNumber(ProgressListener progressListener) {
    this.progressListener = progressListener;

    additionalThreads = Math.max(1,
            ProgramProperties.get("additional-threads", Runtime.getRuntime().availableProcessors() - 1));
    scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(additionalThreads);
}

From source file:io.baku.examples.distro.DistroActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FlutterMain.ensureInitializationComplete(getApplicationContext(), null);
    setContentView(R.layout.flutter_layout);

    flutterView = (FlutterView) findViewById(R.id.flutter_view);
    File appBundle = new File(PathUtils.getDataDirectory(this), FlutterMain.APP_BUNDLE);
    flutterView.runFromBundle(appBundle.getPath(), null);

    poller = new ScheduledThreadPoolExecutor(1);

    context = VAndroidContexts.withDefaults(this, savedInstanceState);

    Futures.addCallback(BlessingsManager.getBlessings(context.getVContext(), this, "blessings", true),
            new FutureCallback<Blessings>() {
                @Override/*from   w w w.j  a  va  2 s. c om*/
                public void onSuccess(final Blessings blessings) {
                    onBlessingsAvailable(blessings);
                }

                @Override
                public void onFailure(final Throwable t) {
                    Log.e(TAG, "Unable to attain blessings", t);
                }
            });
}

From source file:cc.gospy.core.remote.rabbitmq.RemoteScheduler.java

private RemoteScheduler(String host, int port, String virtualHost, String username, String password, int qos,
        int timeoutInSeconds, String... targetQueue) {
    this.checker = new ScheduledThreadPoolExecutor(qos + 1);
    this.timeoutInSeconds = timeoutInSeconds;
    try {//  w  w w  .ja  v  a2  s.co  m
        this.factory = new ConnectionFactory();
        this.factory.setHost(host);
        this.factory.setPort(port);
        this.factory.setVirtualHost(virtualHost);
        this.factory.setUsername(username);
        this.factory.setPassword(password);
        this.init(factory);
        this.declareBase();
        this.targetQueueNames = targetQueue.length != 0 ? targetQueue : new String[] { DEFAULT };
        this.declareTargets(targetQueueNames);
        this.setQos(qos);
        this.declareConsumers();
    } catch (TimeoutException | IOException e) {
        e.printStackTrace();
    }
}

From source file:org.apache.camel.component.javaspace.JavaSpaceConsumer.java

public JavaSpaceConsumer(final JavaSpaceEndpoint endpoint, Processor processor) throws Exception {
    super(endpoint, processor);
    this.concurrentConsumers = endpoint.getConcurrentConsumers();
    this.transactional = endpoint.isTransactional();
    this.transactionTimeout = endpoint.getTransactionTimeout();
    this.verb = endpoint.getVerb();
    this.templateId = endpoint.getTemplateId();
    this.executor = new ScheduledThreadPoolExecutor(this.concurrentConsumers);
}

From source file:net.di2e.ddf.argo.probe.generator.ProbeGenerator.java

/**
 * Starts the timer to send out probes on a set interval.
 *//*from  w  w w.  j ava 2 s . c  o  m*/
public void start() {
    executor = new ScheduledThreadPoolExecutor(NUM_OF_EXECUTOR_THREADS);
    LOGGER.debug("Starting ProbeGenerator to send out probe every {} seconds.", sendFrequency);
    currentTask = executor.scheduleAtFixedRate(sender, 1, sendFrequency, TimeUnit.SECONDS);
}

From source file:gemlite.core.internal.measurement.view.ViewMeasureHelper.java

public final static void init() {
    monitorTask = new MeasureMonitorTask();
    monitorTask.start();/*ww  w  .  j a  v a  2 s .c  o m*/
    scheduledService = new ScheduledThreadPoolExecutor(1);
    tpsTask = new MeasureTPSTask();
    scheduledService.scheduleWithFixedDelay(tpsTask, 1, 2, TimeUnit.SECONDS);
    if (LogUtil.getJMXLog().isInfoEnabled())
        LogUtil.getJMXLog().info("View monitor task started.");
}

From source file:gemlite.core.internal.measurement.index.IndexMeasureHelper.java

public final static void init() {
    monitorTask = new MeasureMonitorTask();
    monitorTask.start();//w w w.  j a  va 2 s . com
    scheduledService = new ScheduledThreadPoolExecutor(1);
    tpsTask = new MeasureTPSTask();
    scheduledService.scheduleWithFixedDelay(tpsTask, 1, 2, TimeUnit.SECONDS);
    if (LogUtil.getJMXLog().isInfoEnabled())
        LogUtil.getJMXLog().info("Index monitor task started.");
}

From source file:com.fusesource.forge.jmstest.threading.LimitedTimeScheduledExecutor.java

public void run() {
    log().info(getClass().getSimpleName() + " " + getName() + " starting.");

    getReleaseManager().register(this);

    executor = new ScheduledThreadPoolExecutor(1);
    executor.scheduleAtFixedRate(getTask(), 0, getInterval(), TimeUnit.SECONDS);

    latch = new CountDownLatch(1);

    new ScheduledThreadPoolExecutor(1).schedule(new Runnable() {

        public void run() {
            try {
                release();/*from w  w  w  .  j a va  2  s .  c  om*/
            } catch (Exception e) {
            }
        }
    }, duration, TimeUnit.SECONDS);

    try {
        latch.await();
    } catch (InterruptedException ie) {
        try {
            release();
        } catch (Exception e) {
        }
    }
    isRunning = false;
    log().info(getClass().getSimpleName() + " " + getName() + " finished.");
}

From source file:org.mule.util.monitor.ExpiryMonitor.java

protected void init() {
    if (monitorFrequency <= 0) {
        throw new IllegalArgumentException(CoreMessages
                .propertyHasInvalidValue("monitorFrequency", new Integer(monitorFrequency)).toString());
    }//from  w  w w .j  a  v  a2 s  .  c  om
    monitors = new ConcurrentHashMap();
    if (scheduler == null) {
        this.scheduler = new ScheduledThreadPoolExecutor(1);
        scheduler.setThreadFactory(new DaemonThreadFactory(name + ".expiry.monitor", contextClassLoader));
        scheduler.scheduleWithFixedDelay(this, 0, monitorFrequency, TimeUnit.MILLISECONDS);
    }
}

From source file:org.graylog2.shared.journal.KafkaJournalTest.java

@Before
public void setUp() throws IOException {
    scheduler = new ScheduledThreadPoolExecutor(1);
    scheduler.prestartCoreThread();/*from   www .  j a  v  a  2s  . c  om*/
    journalDirectory = temporaryFolder.newFolder();

    final File nodeId = temporaryFolder.newFile("node-id");
    Files.write(UUID.randomUUID().toString(), nodeId, StandardCharsets.UTF_8);

    final Configuration configuration = new Configuration() {
        @Override
        public String getNodeIdFile() {
            return nodeId.getAbsolutePath();
        }
    };
    serverStatus = new ServerStatus(configuration, EnumSet.of(ServerStatus.Capability.MASTER),
            new EventBus("KafkaJournalTest"));
}