mirror of
https://github.com/LOOHP/Limbo.git
synced 2026-06-08 05:51:43 +00:00
Performance improvements:
- Update dependencies - Use blocking queue for Tick.asyncTasksQueue - Do not call removed method Thread#stop in Tick#waitAndKillThreads - Use virtual threads for ClientConnection - Add build action Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
This commit is contained in:
@@ -27,12 +27,15 @@ import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class ServerConnection extends Thread {
|
||||
|
||||
private final String ip;
|
||||
private final int port;
|
||||
private final boolean silent;
|
||||
private final ExecutorService virtualThreadExecutor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
private ServerSocket serverSocket;
|
||||
private List<ClientConnection> clients;
|
||||
|
||||
@@ -53,9 +56,9 @@ public class ServerConnection extends Thread {
|
||||
}
|
||||
while (true) {
|
||||
Socket connection = serverSocket.accept();
|
||||
ClientConnection sc = new ClientConnection(connection);
|
||||
clients.add(sc);
|
||||
sc.start();
|
||||
ClientConnection clientTask = new ClientConnection(connection);
|
||||
clients.add(clientTask);
|
||||
virtualThreadExecutor.submit(clientTask);
|
||||
}
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user