I'm creating client-server based application on Java and I've faced a problem related to threads.
So basically, I've a GUI with list of instances of the same class with different ids for each item. When user clicks to one of them, there pop-ups a window where user can type commands to send to server and receive answer according to id of an item in the list. However, because all of them are instances of the same class, they use the same thread (let's call it "Listen") for each item in the list to receive messages from the server. So the problem is, "Listen" thread jumps from one instance to another during receive operation, which causes change in id and following impossibility to properly receive answer.
The question is, is it possible to bind each thread with item, so it doesn't change during execution of receive method.