Class Threading

java.lang.Object
org.graalvm.nativeimage.Threading

public final class Threading extends Object
Functionality related to execution in threads.
Since:
19.0
  • 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 for callback clears the current thread's callback (in which case, the values of interval and unit are ignored).

      Since:
      19.0