Package cn.sliew.milky.common.watchdog
Class DefaultThreadWatchdog
- java.lang.Object
-
- cn.sliew.milky.common.watchdog.DefaultThreadWatchdog
-
- All Implemented Interfaces:
ThreadWatchdog
public class DefaultThreadWatchdog extends Object implements ThreadWatchdog
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longmaxExecutionTimeInMillis()voidregister()Registers the current thread and interrupts the current thread if the takes too long for this thread to invokeThreadWatchdog.unregister().voidunregister()Unregisters the current thread and prevents it from being interrupted.
-
-
-
Method Detail
-
register
public void register()
Description copied from interface:ThreadWatchdogRegisters the current thread and interrupts the current thread if the takes too long for this thread to invokeThreadWatchdog.unregister().- Specified by:
registerin interfaceThreadWatchdog
-
maxExecutionTimeInMillis
public long maxExecutionTimeInMillis()
- Specified by:
maxExecutionTimeInMillisin interfaceThreadWatchdog- Returns:
- The maximum allowed time in milliseconds for a thread to invoke
ThreadWatchdog.unregister()afterThreadWatchdog.register()has been invoked before this ThreadWatchDog starts to interrupting that thread.
-
unregister
public void unregister()
Description copied from interface:ThreadWatchdogUnregisters the current thread and prevents it from being interrupted.- Specified by:
unregisterin interfaceThreadWatchdog
-
-