Guava ListeningScheduledExecutorService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava ListeningScheduledExecutorService class.

This code example shows how to use the following methods:shutdown
  @Override 
  protected void shutDown() throws Exception {
    LOG.info("Stopping LogSaver..."); 
 
    kafkaCancel.cancel();
    scheduledExecutor.shutdown();
 
    logFileWriter.flush();
    logFileWriter.close();
  } 
 
  private void scheduleTasks(Set<Integer> partitions) throws Exception {
    // Don't schedule any tasks when not running 
    if (!isRunning()) {
      LOG.info("Not scheduling when stopping!"); 
      return; 
    } 
 
    subscribe(partitions);
 
3
CodeRank
This code example shows how to use the following methods:shutdownNow
  public void stop() { 
    if (!stopped.compareAndSet(false, true)) {
      return; 
    } 
 
    scheduledExecutor.shutdownNow();
    close(); 
    super.stop(); 
  } 
} 
3
CodeRank
This code example shows how to use the following methods:schedule
    this.service = service;
  } 
 
  @Override 
  public ListenableScheduledFuture<?> schedule(Runnable command, long timeout, TimeUnit unit) {
    return service.schedule(makeContextRunnable(command), timeout, unit);
  } 
 
  @Override 
  public <V> ListenableScheduledFuture<V> schedule(Callable<V> task, long timeout, TimeUnit unit) {
    return service.schedule(makeContextCallable(task), timeout, unit);
  } 
 
  @Override 
  public ListenableScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay,
      long period, TimeUnit unit) {
    return service.scheduleAtFixedRate(makeContextRunnable(command), initialDelay, period, unit);
  } 
 
  @Override 
4
CodeRank