我想通过反对信标发送一个类别物体:(Packet is Serializable
)
public class ServerPlayersListPacket extends Packet {
private static final long serialVersionUID = -7141960214853425631L;
private ArrayList<Player> players;
public ServerPlayersListPacket(ArrayList<Player> players) {
this.setPlayers(players);
}
public ArrayList<Player> getPlayers() {
return new ArrayList<Player>(Collections.synchronizedList(players));
}
public void setPlayers(ArrayList<Player> players) {
this.players = players;
}
}
但<代码>ArrayList仍有问题。 在从另一个网站(I)检索时,OptionalDataException
。
我发现这个问题与<代码>ArrayList同步。 但它如何发挥作用?