Class ThreadPool

java.lang.Object
host.anzo.commons.threading.ThreadPool
All Implemented Interfaces:
IMetric, IShutdownable

public final class ThreadPool extends Object implements IShutdownable, IMetric
Since:
8/19/2021
  • Method Details

    • scheduleGeneral

      @Nullable public @Nullable ScheduledFuture<?> scheduleGeneral(String name, Runnable task, long delay, TimeUnit unit)
      Schedules a general task to be executed after the given delay.
      Parameters:
      name - task name
      task - the task to execute
      delay - the delay in the given time unit
      unit - the time unit of the delay parameter
      Returns:
      a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
    • scheduleGeneral

      @Nullable public @Nullable ScheduledFuture<?> scheduleGeneral(String name, Runnable task, @NotNull @NotNull LocalDateTime dateTime)
    • scheduleGeneralAtFixedRate

      @Nullable public @Nullable ScheduledFuture<?> scheduleGeneralAtFixedRate(String name, Runnable task, long initialDelay, long period, TimeUnit unit)
      Schedules a general task to be executed at fixed rate.
      Parameters:
      name - task name
      task - the task to execute
      initialDelay - the initial delay in the given time unit
      period - the period between executions in the given time unit
      unit - the time unit of the initialDelay and period parameters
      Returns:
      a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
    • executeGeneral

      public void executeGeneral(String name, Runnable task)
      Executes an general task sometime in future in another thread.
      Parameters:
      name - task name
      task - the task to execute
    • getStats

      @NotNull public @NotNull String getStats()
    • onShutdown

      public void onShutdown()
      Specified by:
      onShutdown in interface IShutdownable
    • getMetric

      @NotNull public @NotNull List<MetricResult> getMetric()
      Specified by:
      getMetric in interface IMetric