From 7970faab71c0df772809080ffeb61fd512707f7d Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Wed, 7 Feb 2024 00:19:38 +0100 Subject: [PATCH] copyOnWriteArrayList --- src/main/java/ChatServer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/ChatServer.java b/src/main/java/ChatServer.java index e868615..dc94664 100644 --- a/src/main/java/ChatServer.java +++ b/src/main/java/ChatServer.java @@ -3,12 +3,15 @@ import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public class ChatServer { private ServerSocket serverSocket; private List clients; public ChatServer(int port) { + clients = new CopyOnWriteArrayList<>(); + try { serverSocket = new ServerSocket(port); System.out.println("Started ChatServer on port " + port);