Skip to content

Commit

Permalink
feat: use virtual thread for console
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Oct 22, 2024
1 parent 1c40ffe commit e0e9c7a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions server/src/main/java/org/allaymc/server/AllayServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ public final class AllayServer implements Server {
private final Scheduler scheduler = new AllayScheduler(virtualThreadPool);
@Getter
private final NetworkServer networkServer = new AllayNetworkServer(this);

private final Thread terminalConsoleThread = new AllayTerminalConsoleThread();
private final AllayTerminalConsole terminalConsole = new AllayTerminalConsole(this);
private final AllayTerminalConsole terminalConsole = new AllayTerminalConsole(AllayServer.this);

@Getter
private ScoreboardService scoreboardService;
Expand Down Expand Up @@ -164,7 +162,7 @@ public void start(long initialTime) {
});

if (System.console() != null) {
terminalConsoleThread.start();
Thread.ofVirtual().name("Console Thread").start(terminalConsole::start);
}

((AllayPluginManager) pluginManager).loadPlugins();
Expand Down Expand Up @@ -512,15 +510,4 @@ public Location3fc getCmdExecuteLocation() {
public PermTree getPermTree() {
return DefaultPermissions.OPERATOR;
}

private class AllayTerminalConsoleThread extends Thread {
public AllayTerminalConsoleThread() {
super("Console Thread");
}

@Override
public void run() {
terminalConsole.start();
}
}
}

0 comments on commit e0e9c7a

Please sign in to comment.