From 3e09cd415e4dacdce856719863d4b2f8f90591b7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 1 Jan 2025 10:45:51 -0600 Subject: [PATCH] thread count on boot --- src/engine/server/world/WorldServer.java | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index fe1752e9..62ac5654 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -520,9 +520,46 @@ public class WorldServer { Logger.info("Starting Player Update Thread"); UpdateThread.startUpdateThread(); + + printThreads(); + Logger.info("Threads Running:"); + return true; } + public static void printThreads() { + // Get the root thread group + ThreadGroup rootGroup = Thread.currentThread().getThreadGroup(); + while (rootGroup.getParent() != null) { + rootGroup = rootGroup.getParent(); + } + + // Estimate the number of threads + int activeThreads = rootGroup.activeCount(); + + // Create an array to hold the threads + Thread[] threads = new Thread[activeThreads]; + + // Get the active threads + rootGroup.enumerate(threads, true); + + int availableThreads = Runtime.getRuntime().availableProcessors(); + + // Print the count + Logger.info("Total threads in application: " + threads.length + " / " + availableThreads + " Total Threads On Machine"); + if(threads.length > (int)(availableThreads * 0.75f)){ + Logger.error("WARNING! Too many threads are being used, hardware update recommended"); + } + + // Optionally, list the thread names + Logger.info("Active threads:"); + for (Thread thread : threads) { + if (thread != null) { + Logger.info(thread.getName()); + } + } + } + protected boolean initDatabaselayer() { // Try starting a GOM <-> DB connection.