Browse Source

thread count on boot

lakebane2
FatBoy-DOTC 2 weeks ago
parent
commit
3e09cd415e
  1. 37
      src/engine/server/world/WorldServer.java

37
src/engine/server/world/WorldServer.java

@ -520,9 +520,46 @@ public class WorldServer { @@ -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.

Loading…
Cancel
Save