diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java
index bacf45bcb..a8812bcee 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/WorldGenerationQueue.java
@@ -17,6 +17,7 @@ import com.seibel.distanthorizons.core.file.fullDatafile.FullDataFileHandler;
import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
import com.seibel.distanthorizons.core.render.renderer.IDebugRenderable;
import com.seibel.distanthorizons.core.util.ThreadUtil;
+import com.seibel.distanthorizons.core.util.objects.DhThreadFactory;
import com.seibel.distanthorizons.core.util.objects.UncheckedInterruptedException;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.IWrapperFactory;
@@ -496,6 +497,8 @@ public class WorldGenerationQueue implements Closeable, IDebugRenderable
// executor handler methods //
//==========================//
+ public static final DhThreadFactory THREAD_FACTORY = new DhThreadFactory("Gen-Worker-Thread", Thread.MIN_PRIORITY);
+
/**
* Creates a new executor.
* Does nothing if an executor already exists.
@@ -523,7 +526,7 @@ public class WorldGenerationQueue implements Closeable, IDebugRenderable
worldGeneratorThreadPool.shutdown();
}
- worldGeneratorThreadPool = ThreadUtil.makeRateLimitedThreadPool(threadPoolSize, "DH-Gen-Worker-Thread", Thread.MIN_PRIORITY, Config.Client.Advanced.MultiThreading.runTimeRatioForWorldGenerationThreads);
+ worldGeneratorThreadPool = ThreadUtil.makeRateLimitedThreadPool(threadPoolSize, THREAD_FACTORY, Config.Client.Advanced.MultiThreading.runTimeRatioForWorldGenerationThreads);
}
/**
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/ThreadUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/ThreadUtil.java
index 6ae635ad8..acf41f67e 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/util/ThreadUtil.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/util/ThreadUtil.java
@@ -20,30 +20,44 @@ public class ThreadUtil
// create rate limited thread pool //
- public static RateLimitedThreadPoolExecutor makeRateLimitedThreadPool(int poolSize, String name, ConfigEntry runTimeRatioConfigEntry) { return makeRateLimitedThreadPool(poolSize, name, DEFAULT_RELATIVE_PRIORITY, runTimeRatioConfigEntry); }
+ public static RateLimitedThreadPoolExecutor makeRateLimitedThreadPool(int poolSize, String name, ConfigEntry runTimeRatioConfigEntry)
+ {
+ return makeRateLimitedThreadPool(poolSize, name, DEFAULT_RELATIVE_PRIORITY, runTimeRatioConfigEntry);
+ }
public static RateLimitedThreadPoolExecutor makeRateLimitedThreadPool(int poolSize, String name, int relativePriority, ConfigEntry runTimeRatioConfigEntry)
+ {
+ DhThreadFactory threadFactory = new DhThreadFactory("DH-" + name, Thread.NORM_PRIORITY + relativePriority);
+ return makeRateLimitedThreadPool(poolSize, threadFactory, runTimeRatioConfigEntry);
+ }
+ public static RateLimitedThreadPoolExecutor makeRateLimitedThreadPool(int poolSize, DhThreadFactory threadFactory, ConfigEntry runTimeRatioConfigEntry)
{
// remove the old listener if one exists
- if (THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.containsKey(name))
+ if (THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.containsKey(threadFactory.threadName))
{
// note: this assumes only one thread pool exists with a given name
- THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.get(name).close();
- THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.remove(name);
+ THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.get(threadFactory.threadName).close();
+ THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.remove(threadFactory.threadName);
}
- RateLimitedThreadPoolExecutor executor = makeRateLimitedThreadPool(poolSize, name, runTimeRatioConfigEntry.get(), relativePriority);
+
+ RateLimitedThreadPoolExecutor executor = makeRateLimitedThreadPool(poolSize, runTimeRatioConfigEntry.get(), threadFactory);
ConfigChangeListener changeListener = new ConfigChangeListener<>(runTimeRatioConfigEntry, (newRunTimeRatio) -> { executor.runTimeRatio = newRunTimeRatio; });
- THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.put(name, changeListener);
+ THREAD_CHANGE_LISTENERS_BY_THREAD_NAME.put(threadFactory.threadName, changeListener);
return executor;
}
+
/** should only be used if there isn't a config controlling the run time ratio of this thread pool */
public static RateLimitedThreadPoolExecutor makeRateLimitedThreadPool(int poolSize, String name, Double runTimeRatio, int relativePriority)
{
return new RateLimitedThreadPoolExecutor(poolSize, runTimeRatio, new DhThreadFactory("DH-" + name, Thread.NORM_PRIORITY + relativePriority));
}
+ public static RateLimitedThreadPoolExecutor makeRateLimitedThreadPool(int poolSize, Double runTimeRatio, DhThreadFactory threadFactory)
+ {
+ return new RateLimitedThreadPoolExecutor(poolSize, runTimeRatio, threadFactory);
+ }
// create thread pool //