I'm make simple game(with server) in java. I would like to receive packets from the server to a certain time, but do not know how to solve it.
What is an effective solution?
For example in pseudo:
Thread one:
tryToGetPacketFromServer(){
GETPACKET...
}
Thread two:
timer(){
if gettin time of thread one > 5 second;
print errorr and stop thread one..
}