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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 ScheduledExecutorService Questions & Answers:

See Code Examples for Java 8 ScheduledExecutorService Methods: