Package cn.sliew.milky.common.watchdog
Enum ThreadWatchdogs
- java.lang.Object
-
- java.lang.Enum<ThreadWatchdogs>
-
- cn.sliew.milky.common.watchdog.ThreadWatchdogs
-
- All Implemented Interfaces:
Serializable,Comparable<ThreadWatchdogs>
public enum ThreadWatchdogs extends Enum<ThreadWatchdogs>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ThreadWatchdognewInstance(long interval, long maxExecutionTime, LongSupplier relativeTimeSupplier, BiFunction<Long,Runnable,ScheduledFuture<?>> scheduler)Returns an implementation that checks for each fixed interval if there are threads that have invokedThreadWatchdog.register()and notThreadWatchdog.unregister()and have been in this state for longer than the specified max execution interval and then interrupts these threads.ThreadWatchdognoop()static ThreadWatchdogsvalueOf(String name)Returns the enum constant of this type with the specified name.static ThreadWatchdogs[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static ThreadWatchdogs[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ThreadWatchdogs c : ThreadWatchdogs.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ThreadWatchdogs valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
newInstance
public ThreadWatchdog newInstance(long interval, long maxExecutionTime, LongSupplier relativeTimeSupplier, BiFunction<Long,Runnable,ScheduledFuture<?>> scheduler)
Returns an implementation that checks for each fixed interval if there are threads that have invokedThreadWatchdog.register()and notThreadWatchdog.unregister()and have been in this state for longer than the specified max execution interval and then interrupts these threads.- Parameters:
interval- The fixed interval to check if there are threads to interruptmaxExecutionTime- The time a thread has the execute an operation.relativeTimeSupplier- A supplier that returns relative timescheduler- A scheduler that is able to execute a command for each fixed interval
-
noop
public ThreadWatchdog noop()
- Returns:
- A noop implementation that does not interrupt threads and is useful for testing and pre-defined grok expressions.
-
-