Desno365 / Adrenaline-ing-sw-1-project

Computer engineering project for the course: "Software Engineering 1"
0 stars 0 forks source link

Fix possible concurrent problems #4

Closed Desno365 closed 5 years ago

Desno365 commented 5 years ago

Made all the interfacing methods between network classes and other classes synchronized:

public synchronized void processMessage(Message message); Method in the client. I think this can be called multiple times if the client receives multiple messages simultaneously. If made synchronized messages will be processed sequentially.

public synchronized void onClientRegistration(ConnectionToClientInterface client); public synchronized void onMessageReceived(ConnectionToClientInterface client, Message message); These are the two methods in the server. These methods can be called concurrently since there may be multiple clients connected. If made synchronized their execution will be sequential.

Tried to run the main of the server and of multiple clients and everything seems to work as usual.