Interface ThreadContext


  • public interface ThreadContext
    An optional context available from the Root lookup, providing the ability to query whether code is running on the Root thread, and to pass tasks to invoke on the Root thread.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void invokeLater​(Runnable task)
      Execute a task on the Root thread.
      boolean isInUpdate()
      Check whether the current thread is the active thread executing inside a Root update.
      boolean isRootThread()
      Check whether the current thread is the thread currently driving a Root implementation.
    • Method Detail

      • isInUpdate

        boolean isInUpdate()
        Check whether the current thread is the active thread executing inside a Root update.
        Returns:
        current thread is in Root update
      • isRootThread

        boolean isRootThread()
        Check whether the current thread is the thread currently driving a Root implementation. This is a looser check than isInUpdate() where a Root implementation may be driven by an external context - eg. UI event thread. It will always return true when isInUpdate() returns true. This method does not return true if a thread has been returned to a pool. As a guide, it will return true if blocking the current thread would block the Root from executing.
        Returns:
        current thread is Root executing thread
      • invokeLater

        void invokeLater​(Runnable task)
        Execute a task on the Root thread. The task should carefully check that its state is still valid - eg. a component should check that it has not been removed from the Root hierarchy.
        Parameters:
        task - task to be executed