Skip to content

Commit

Permalink
Ensure the common thread pool has at least 2 threads.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatRedox committed Oct 1, 2023
1 parent 39956ce commit 9a22eaf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chunky/src/java/se/llbit/chunky/main/Chunky.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public static void main(final String[] args) {
if (cmdline.mode == CommandLineOptions.Mode.CLI_OPERATION) {
exitCode = cmdline.exitCode;
} else {
commonThreads = new ForkJoinPool(PersistentSettings.getNumThreads());
// Initialize the common thread pool.
getCommonThreads();

Chunky chunky = new Chunky(cmdline.options);
chunky.headless = cmdline.mode == Mode.HEADLESS_RENDER || cmdline.mode == Mode.CREATE_SNAPSHOT;
Expand Down Expand Up @@ -341,7 +342,7 @@ public void update() {
*/
public static ForkJoinPool getCommonThreads() {
if (commonThreads == null) {
commonThreads = new ForkJoinPool(PersistentSettings.getNumThreads());
commonThreads = new ForkJoinPool(Math.max(PersistentSettings.getNumThreads(), 2));
}
return commonThreads;
}
Expand Down

0 comments on commit 9a22eaf

Please sign in to comment.