Package 

Class CommonTaskExecutor

    • Method Summary

      Modifier and Type Method Description
      <T> ScheduledFuture<out Object> scheduleAtFixedRate(CommonTaskExecutor.Task<T> task, T target, long initialDelay, long period, TimeUnit unit, String name) Run {@code task} periodically providing it with {@code target}Important implementation detail here is that internally we do not hold any strong referencesto {@code target} which means it can be GCed even while periodic task is still scheduled.
      void shutdown()
      List<Runnable> shutdownNow()
      boolean isShutdown()
      boolean isTerminated()
      boolean awaitTermination(long timeout, TimeUnit unit)
      void execute(Runnable command)
      • Methods inherited from class java.util.concurrent.AbstractExecutorService

        invokeAll, invokeAny, submit, submit
      • Methods inherited from class java.util.concurrent.ExecutorService

        awaitTermination, isShutdown, isTerminated, shutdown, shutdownNow
      • Methods inherited from class java.util.concurrent.Executor

        execute
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • scheduleAtFixedRate

         <T> ScheduledFuture<out Object> scheduleAtFixedRate(CommonTaskExecutor.Task<T> task, T target, long initialDelay, long period, TimeUnit unit, String name)

        Run {@code task} periodically providing it with {@code target}

        Important implementation detail here is that internally we do not hold any strong referencesto {@code target} which means it can be GCed even while periodic task is still scheduled.

        If {@code target} is GCed periodic task is canceled.

        This method should be able to schedule task in majority of cases. The only reasonable casewhen this would fail is when task is being scheduled during JVM shutdown. In this case thismethod will return 'fake' future that can still be canceled to avoid confusing callers.

        Parameters:
        task - task to run.
        target - target object to pass to task
        initialDelay - initialDelay, see
        period - period, see scheduleAtFixedRate
        unit - unit, see scheduleAtFixedRate
        name - name to use in logs when task cannot be scheduled