Class Threading
- Since:
- 19.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface that a callback handler needs to implement.static interface
Provides methods that are available during the execution of aThreading.RecurringCallback
. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
registerRecurringCallback
(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 handler
that 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
null
forcallback
clears the current thread's callback (in which case, the values ofinterval
andunit
are ignored).- Since:
- 19.0
-