thread count on boot

lakebane2
FatBoy-DOTC 2025-01-01 10:45:51 -06:00
parent 1098265145
commit 3e09cd415e
1 changed files with 37 additions and 0 deletions

View File

@ -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.