Multiplayer. Message depends on another message

Alo

I have a multiplayer card game. On my client I received 2 message.

message no 1. The player profil
message no 2. List of players

public void getPlayerProfil(GameEvent event) {


}

public void getPlayerList(GameEvent event) {

some code depends on playerProfil

}

Sometimes I get the message no.2 first which is not good. Should I use some kind of locking or is the only way to only received 1 message with playerProfi and playerlist.

Thx in advance

You dont tell us how you are sending these messages.

TCP is gaurantered in order.

UDP is not gauranteed anything.

RMI is synchronous per call.

I found out that I was using UDP. Switch to TCP solved the problem