Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the common thread pool has at least 2 threads. #1641

Merged
merged 2 commits into from
Oct 3, 2023
Merged
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
6 changes: 4 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,8 @@ public void update() {
*/
public static ForkJoinPool getCommonThreads() {
if (commonThreads == null) {
commonThreads = new ForkJoinPool(PersistentSettings.getNumThreads());
// use at least two threads to prevent deadlocks in some java versions (see #1631)
commonThreads = new ForkJoinPool(Math.max(PersistentSettings.getNumThreads(), 2));
leMaik marked this conversation as resolved.
Show resolved Hide resolved
}
return commonThreads;
}
Expand Down
Loading