Interface IClientThread
- All Superinterfaces:
RuneLiteWrapper<net.runelite.client.callback.ClientThread>
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 TypeMethodDescriptionvoidInvokes a runnable on the client thread.<T> TinvokeAndWait(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
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- theRunnableto execute on the client thread
-
invokeAndWait
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- theCallableto execute on the client thread- Returns:
- the result returned by the callable
-