Interface IClientThread

All Superinterfaces:
RuneLiteWrapper<net.runelite.client.callback.ClientThread>

public interface IClientThread extends RuneLiteWrapper<net.runelite.client.callback.ClientThread>
Provides utilities for executing code on the game client thread.

Many game operations must be performed on the client thread to ensure thread safety and proper synchronization with the game engine. This interface provides methods to schedule code execution on the client thread from other threads.

This interface wraps the RuneLite ClientThread and provides a convenient API for thread-safe game interactions.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    invoke(Runnable runnable)
    Invokes a runnable on the client thread.
    <T> T
    invokeAndWait(Callable<T> callable)
    Invokes a callable on the client thread and waits for the result.

    Methods inherited from interface net.storm.api.domain.RuneLiteWrapper

    getWrapped
  • Method Details

    • invoke

      void invoke(Runnable runnable)
      Invokes a runnable on the client thread.

      The provided runnable will be scheduled to execute on the next available client thread cycle. This method returns immediately and does not wait for the runnable to complete.

      Use this method when you need to perform game operations from a non-client thread and do not need to wait for a result.

      Parameters:
      runnable - the Runnable to execute on the client thread
    • invokeAndWait

      <T> T invokeAndWait(Callable<T> callable)
      Invokes a callable on the client thread and waits for the result.

      The provided callable will be executed on the client thread, and this method will block until execution completes and return the result. This is useful when you need to retrieve data from the game state while on a non-client thread.

      Note: Calling this method from the client thread itself may cause a deadlock. Use IClient.isClientThread() to check the current thread before calling this method.

      Type Parameters:
      T - the type of the result returned by the callable
      Parameters:
      callable - the Callable to execute on the client thread
      Returns:
      the result returned by the callable