Class Threading
- Since:
- 19.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface that a callback handler needs to implement.static interfaceProvides methods that are available during the execution of aThreading.RecurringCallback. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidregisterRecurringCallback(long interval, TimeUnit unit, Threading.RecurringCallback callback) This method is intended for expert users.
-
Method Details
-
registerRecurringCallback
public static void registerRecurringCallback(long interval, TimeUnit unit, Threading.RecurringCallback callback) This method is intended for expert users.Registers a
callback handlerthat is called by the current thread approximately at the provided interval. This functionality is only supported if the native binary is built with-H:+SupportRecurringCallback. Note that only carefully crafted, uninterruptible code can execute safely in a recurring callback. Executing any other code easily results in deadlocks, crashes, and difficult-to-debug anomalies.Only one callback can be active per thread. Each thread can have its own callback with a different interval (or none at all). No guarantees are made about the actual interval. For example, when the thread is waiting for a lock or executing native code, no callback can be done.
Exceptions that are thrown during the execution of the callback and that are not caught in the callback are ignored.
Threading.RecurringCallbackAccess.throwException(Throwable)can be used to explicitly throw an exception that is not ignored.Specifying
nullforcallbackclears the current thread's callback (in which case, the values ofintervalandunitare ignored).- Since:
- 19.0
-