I have the following code in ServerConnectionManager:
public class ServerConnectionManager implements Runnable {
private DatagramPacket receivedPacket;
You need to create a new DatagramPacket
per receive if you want to start a new thread to handle it. Otherwise one thread is synchronized on it during receive()
while the other thread is trying to call getPort()
. The design is invalid in any case, as the receive()
will overwrite everything in the previously received datagram while the thread is trying to process it.