Commit 60e71463 authored by dreis2211's avatar dreis2211 Committed by Andy Wilkinson

Reduce started threads in OnClassCondition

Prior to this commit, OnClassCondition started a thread even if the number of
passed autoconfiguration class candidates never exceeded 1. This commit only
starts a thread if there is actually work to split in half.

See gh-22294
parent 196d2053
...@@ -49,7 +49,7 @@ class OnClassCondition extends FilteringSpringBootCondition { ...@@ -49,7 +49,7 @@ class OnClassCondition extends FilteringSpringBootCondition {
// Split the work and perform half in a background thread if more than one // Split the work and perform half in a background thread if more than one
// processor is available. Using a single additional thread seems to offer the // processor is available. Using a single additional thread seems to offer the
// best performance. More threads make things worse. // best performance. More threads make things worse.
if (Runtime.getRuntime().availableProcessors() > 1) { if (autoConfigurationClasses.length > 1 && Runtime.getRuntime().availableProcessors() > 1) {
return resolveOutcomesThreaded(autoConfigurationClasses, autoConfigurationMetadata); return resolveOutcomesThreaded(autoConfigurationClasses, autoConfigurationMetadata);
} }
else { else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment