Package host.anzo.commons.threading
Class ThreadPool
java.lang.Object
host.anzo.commons.threading.ThreadPool
- All Implemented Interfaces:
IMetric,IShutdownable
- Since:
- 8/19/2021
-
Method Summary
Modifier and TypeMethodDescriptionvoidexecuteGeneral(String name, Runnable task) Executes an general task sometime in future in another thread.@NotNull List<MetricResult>@NotNull StringgetStats()void@Nullable ScheduledFuture<?>scheduleGeneral(String name, Runnable task, long delay, TimeUnit unit) Schedules a general task to be executed after the given delay.@Nullable ScheduledFuture<?>scheduleGeneral(String name, Runnable task, @NotNull LocalDateTime dateTime) @Nullable ScheduledFuture<?>scheduleGeneralAtFixedRate(String name, Runnable task, long initialDelay, long period, TimeUnit unit) Schedules a general task to be executed at fixed rate.
-
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 nametask- the task to executedelay- the delay in the given time unitunit- 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 nametask- the task to executeinitialDelay- the initial delay in the given time unitperiod- the period between executions in the given time unitunit- 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
Executes an general task sometime in future in another thread.- Parameters:
name- task nametask- the task to execute
-
getStats
-
onShutdown
public void onShutdown()- Specified by:
onShutdownin interfaceIShutdownable
-
getMetric
-