Class PlayerIds
java.lang.Object
org.xxdc.oss.example.PlayerIds
Manages player IDs for a game system. This class provides thread-safe operations for generating
and retrieving player IDs.
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerIds(int initialValue) Constructs a new PlayerIds instance with the specified initial value. -
Method Summary
Modifier and TypeMethodDescriptionintRetrieves the current value of the next player ID without incrementing it.intAtomically retrieves the current value of the next player ID and increments it.
-
Constructor Details
-
PlayerIds
public PlayerIds(int initialValue) Constructs a new PlayerIds instance with the specified initial value.- Parameters:
initialValue- The initial value for the next player ID.
-
-
Method Details
-
getNextId
public int getNextId()Retrieves the current value of the next player ID without incrementing it.- Returns:
- The current value of the next player ID.
-
getNextIdAndIncrement
public int getNextIdAndIncrement()Atomically retrieves the current value of the next player ID and increments it.- Returns:
- The current value of the next player ID before incrementing.
-