Package net.storm.sdk.game
Class GameThread
java.lang.Object
net.storm.sdk.game.GameThread
Provides utilities for executing code on the game client thread.
Many game client operations must be performed on the client thread to avoid
concurrency issues and ensure thread safety.
This class offers methods to invoke code synchronously or asynchronously on the client thread, with options to wait for completion and retrieve results.
Example usage:
// Execute code on the client thread without waiting
GameThread.invoke(() -> {
// This code runs on the client thread
Client.interact(identifier, opcode, param0, param1);
});
// Execute code and wait for it to complete
GameThread.invokeAndWait(() -> {
// This code runs on the client thread
// The calling thread blocks until completion
someClientOperation();
});
// Execute code and get a result
int result = GameThread.invokeAndWait(() -> {
return Client.getBoostedSkillLevel(Skill.HITPOINTS);
});
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidInvokes a runnable on the client thread.static voidinvokeAndWait(Runnable runnable) Schedules an execution on the client thread and waits until execution.static <T> TinvokeAndWait(Callable<T> callable) Schedules an execution on the client thread and waits for the result.
-
Constructor Details
-
GameThread
public GameThread()
-
-
Method Details
-
invoke
Invokes a runnable on the client thread. This method returns immediately and does not wait for the runnable to complete.- Parameters:
runnable- the runnable to invoke
-
invokeAndWait
Schedules an execution on the client thread and waits for the result. This method blocks until the callable completes and returns its result.- Type Parameters:
T- the type of the result- Parameters:
callable- the callable to invoke- Returns:
- the result of the callable
-
invokeAndWait
Schedules an execution on the client thread and waits until execution. This method blocks until the runnable completes.- Parameters:
runnable- the runnable to invoke
-