diff --git a/base/src/main/java/de/staropensource/sosengine/base/Engine.java b/base/src/main/java/de/staropensource/sosengine/base/Engine.java index 8da30c9..47c30c8 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/Engine.java +++ b/base/src/main/java/de/staropensource/sosengine/base/Engine.java @@ -72,14 +72,26 @@ public final class Engine implements SubsystemMainClass { @Getter private static Engine instance = null; + /** + * Contains the thread group of the engine. + * + * @since v1-alpha2 + * + * -- GETTER -- + * Returns the thread group of the engine. + * + * @return engine thread group + * @since v1-alpha2 + */ + @Getter + private static final ThreadGroup threadGroup = new ThreadGroup("sos!engine"); + /** * Logger instance. * * @see LoggerInstance * @since v1-alpha0 */ - @SuppressWarnings("NotNullFieldNotInitialized") - @NotNull private LoggerInstance logger; /** diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java index 55951ad..a26a98d 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java @@ -168,7 +168,10 @@ public class EventHelper { }; if (EngineConfiguration.getInstance().isOptimizeEvents()) - Thread.ofVirtual().start(eventCode); + Thread + .ofVirtual() + .name("Event " + event.getName() + "[" + arguments + "]") + .start(eventCode); else eventCode.run(); } diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java index ed1f487..fb962af 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java @@ -129,7 +129,7 @@ public final class Logger { public static void startLoggingThread() { if (loggingThread == null) { // Logging thread not defined, create and start new one - loggingThread = Thread.ofPlatform().start(() -> { + Runnable threadLogic = () -> { while (true) { // Run in loop // Stop thread when engine is shutting down if (Engine.getInstance().isShuttingDown()) @@ -144,7 +144,15 @@ public final class Logger { Thread.sleep(EngineConfiguration.getInstance().getLoggerPollingSpeed()); } catch (Exception ignored) {} } - }); + }; + + loggingThread = Thread + .ofPlatform() + .daemon() + .name("Logging thread") + .group(Engine.getThreadGroup()) + .stackSize(10) + .start(threadLogic); } else { // Restart logging thread if dead if (!loggingThread.isAlive())