Okay, so I have a client/server test going on, and I am passing the Integer playerID to a thread where it gives the int value to a simple Player object, than increments playerID by 1.
public static void main(String[] args) throws IOException {
Vector<Player> player = new Vector<Player>();
SlickServer ss = new SlickServer();
ss.setVisible(true);
ServerSocket serverSocket = new ServerSocket(4444);
boolean listening = true;
Integer playerID = new Integer(0);
while(listening){
ss.textArea.append("Waiting to connect with player: " + playerID.intValue() + "\n");
new ClientThread(serverSocket.accept(), player, playerID, ss.textArea).start();
ss.textArea.append("Waiting to connect with player: " + playerID.intValue() + "\n");
}
serverSocket.close();
System.exit(0);
}
and here's where it increments it in the thread:
public ClientThread(Socket acceptedSocket, Vector<Player> players, Integer playerID, JTextArea textArea){
super("ClientThread");
this.acceptedSocket = acceptedSocket;
this.players = players;
players.add(new Player(50,50, playerID.intValue()));
if(players != null)
System.out.println("Not Null: " + players.size());
boolean b = false;
for(int i = 0; i < players.size(); i++){
if(!b){
if(players.get(i).id == playerID){
me = players.get(i);
b = true;
}
}
}
playerID = new Integer(playerID.intValue() + 1);
this.textArea = textArea;
}