Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/com/thunder/novaapi/Core/NovaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ public void onServerStarting(ServerStartingEvent event) {
}
MinecraftServer server = event.getServer();
initializeAsyncAndChunkSystems(server);
ThreadMonitor.startMonitoring();
if (NovaAPIConfig.isMemoryThreadLogsEnabled()) {
ThreadMonitor.startMonitoring();
}
Comment on lines +140 to +142
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Start monitor when thread-log config is toggled on

Gating ThreadMonitor.startMonitoring() to server startup means enableMemoryThreadLogs can no longer be enabled dynamically: with the default false, the monitor thread never starts, and onConfigReload (same file) does not start it later, so thread/deadlock monitoring remains disabled until a full server restart. Before this change, the monitor was already running and the config flag took effect on the next cycle.

Useful? React with 👍 / 👎.

}

@SubscribeEvent
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/thunder/novaapi/async/AsyncTaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ private static RejectedExecutionHandler callerRunsWithBackoff(String prefix) {
executor.getQueue().size(),
callerRuns);
}
try {
TimeUnit.MILLISECONDS.sleep(5);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
task.run();
};
}
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/com/thunder/novaapi/utils/ThreadMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.util.Map;

public class ThreadMonitor {

Expand Down Expand Up @@ -51,12 +50,15 @@ private static void logAllThreads() {
if (!NovaAPIConfig.isMemoryThreadLogsEnabled()) {
return;
}
Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
NovaAPI.LOGGER.debug("📌 Active Threads: {}", threads.size());
ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
int threadCount = threadBean.getThreadCount();
NovaAPI.LOGGER.debug("📌 Active Threads: {}", threadCount);

for (Thread thread : threads.keySet()) {
NovaAPI.LOGGER.trace("🧵 Thread Name: {} | ID: {} | State: {} | Priority: {}",
thread.getName(), thread.threadId(), thread.getState(), thread.getPriority());
if (NovaAPI.LOGGER.isTraceEnabled()) {
for (Thread thread : Thread.getAllStackTraces().keySet()) {
NovaAPI.LOGGER.trace("🧵 Thread Name: {} | ID: {} | State: {} | Priority: {}",
thread.getName(), thread.threadId(), thread.getState(), thread.getPriority());
}
}
}

Expand Down