Java 8 ScheduledExecutorService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ScheduledExecutorService class.

This code example shows how to use the following methods: scheduleAtFixedRate
    private final TimeUnit rateUnit;
    private final ScheduledFuture<?> future;
 
    public MeterMetric(ScheduledExecutorService tickThread, TimeUnit rateUnit) {
        this.rateUnit = rateUnit;
        this.future = tickThread.scheduleAtFixedRate(new Runnable() {
            @Override 
            public void run() { 
                tick(); 
            } 
        }, INTERVAL, INTERVAL, TimeUnit.SECONDS);
    } 
 
    public TimeUnit rateUnit() {
        return rateUnit;
    } 
 
    /** 
     * Updates the moving averages. 
     */ 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: scheduleAtFixedRate
    _executor.shutdown();
  } 
 
  @Test 
  public void testSetPeriod() { 
    final RateLimiter rl = new RateLimiter(0,
                                     MAXPERIOD,
                                     20, 
                                     _executor);
 
 
    _executor.scheduleAtFixedRate(new Runnable() {
      private int _period = 300;
 
      @Override 
      public void run() { 
        rl.setPeriod(_period);
        _period += 50;
      } 
    }, 0, 100, TimeUnit.MILLISECONDS);
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: shutdown
        } 
    } 
 
    @Override 
    public void close() { 
        this.executor.shutdown();
    } 
 
    private class ExpirationTask implements Runnable {
        private final String id;
 
        public ExpirationTask(String id) {
            this.id = id;
        } 
 
        @Override 
        public void run() { 
            SessionExpirationScheduler.this.expirationFutures.remove(this.id);
            InfinispanWebLogger.ROOT_LOGGER.tracef("Expiring session %s", this.id);
            Batch batch = SessionExpirationScheduler.this.batcher.startBatch();
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: shutdownNow
        this.executor = executor;
    } 
 
    @Override 
    public void stop(StopContext context) {
        this.executor.shutdownNow();
    } 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: scheduleWithFixedDelay
        Runnable task = mock(Runnable.class);
        long delay = 10L;
        long period = 20L;
        TimeUnit unit = TimeUnit.SECONDS;
 
        when(this.executor.scheduleWithFixedDelay(task, delay, period, unit)).thenReturn(expected);
 
        ScheduledFuture<?> result = this.subject.scheduleWithFixedDelay(task, delay, period, unit);
 
        assertSame(expected, result);
    } 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: schedule
     * {@inheritDoc} 
     * @see java.util.concurrent.ScheduledExecutorService#schedule(java.util.concurrent.Callable, long, java.util.concurrent.TimeUnit) 
     */ 
    @Override 
    public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
        return this.executor.schedule(callable, delay, unit);
    } 
 
    /** 
     * {@inheritDoc} 
     * @see java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit) 
     */ 
    @Override 
    public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
        synchronized (this.futures) {
            if (this.shutdown) throw new RejectedExecutionException();
            ScheduledFuture<?> future = this.executor.scheduleAtFixedRate(command, initialDelay, period, unit);
            this.futures.add(future);
            return future;
        } 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: shutdownNow
    if (_serverWithoutCompression != null)
    { 
      _serverWithoutCompression.stop();
    } 
    _engine.shutdown();
    _scheduler.shutdownNow();
 
    restoreLogging(NETTY_CLIENT_LOGGER);
    restoreLogging(ASYNC_POOL_LOGGER);
  } 
} 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: scheduleAtFixedRate
    private final TimeUnit rateUnit;
    private final ScheduledFuture<?> future;
 
    public MeterMetric(ScheduledExecutorService tickThread, TimeUnit rateUnit) {
        this.rateUnit = rateUnit;
        this.future = tickThread.scheduleAtFixedRate(new Runnable() {
            @Override 
            public void run() { 
                tick(); 
            } 
        }, INTERVAL, INTERVAL, TimeUnit.SECONDS);
    } 
 
    public TimeUnit rateUnit() {
        return rateUnit;
    } 
 
    /** 
     * Updates the moving averages. 
     */ 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: scheduleWithFixedDelay
 
        s_dataDir = new File(data);
        FileProjectManager.initialize(s_dataDir);
        ImportingManager.initialize(this);
 
        service.scheduleWithFixedDelay(new AutoSaveTimerTask(), AUTOSAVE_PERIOD, 
                AUTOSAVE_PERIOD, TimeUnit.MINUTES);
 
        logger.trace("< initialize"); 
    } 
 
    @Override 
    public void destroy() { 
        logger.trace("> destroy"); 
 
        // cancel automatic periodic saving and force a complete save. 
        if (_timer != null) { 
            _timer.cancel(); 
            _timer = null; 
        } 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: awaitTermination, shutdown, shutdownNow
		logger.info("Shutting down deployment synchronization"); 
		if (this.executor != null) {
			if (future != null) {
				this.future.cancel(false);
			} 
			this.executor.shutdown();
			try { 
				if (!this.executor.awaitTermination(10, TimeUnit.SECONDS)) {
					this.executor.shutdownNow();
				} 
			} catch (InterruptedException e) {
				logger.debug("Interrupted exception while waiting for executor shutdown"); 
			} 
		} 
		logger.info("Deployment synchronization stopped"); 
	} 
	 
	private class TriggerDeploymentSync implements Runnable {
 
		@Override 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 ScheduledExecutorService Questions & Answers:

See Code Examples for Java 8 ScheduledExecutorService Methods: