Как использовать очередь в java networking для управления клиентами?
Hello, guys i need your help and its very very urgent please. I am working on a simple program which is a Java Network Guess Game for Multi Players. It's working using threads to start multi players and accept them via server but i want to do some changes, for example, using it by multi players, what i want to keep players in queue and start initial three players or more to play game others should be in queue or later server will allow others to play. Please reply as soon as possible, i will appreciate if you design a simple sample code for me...thanks in advance
Что я уже пробовал:
Я использовал следующее, Но это не работает мой друг, вы можете увидеть код сервера
<pre lang="java">public class Server { public static Queue<PlayerController> players = new LinkedList<>(); public static void main(String[] args) { try(ServerSocket serverSocket = new ServerSocket(1234)) { int clientNumber = 0; while(true) { clientNumber++; if(clientNumber != 6) { PlayerController playerRequest = new PlayerController(serverSocket.accept()); players.add(playerRequest); System.out.println("Server Added Client " + clientNumber + "To Queue..."); }else { new PlayerController(serverSocket.accept()); //PlayerController playerResponse = new PlayerController(serverSocket.accept()); PlayerController.userNotification(); } //while(clientNumber >= 3) { // } } } catch(IOException e) { System.out.println("Server exception " + e.getMessage()); } } }