Skip to content

Commit

Permalink
Reduce started threads in OnClassCondition
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dreis2211 authored and wilkinsona committed Jul 14, 2020
1 parent 196d205 commit 60e7146
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -49,7 +49,7 @@ protected final ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses
// 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
// best performance. More threads make things worse.
if (Runtime.getRuntime().availableProcessors() > 1) {
if (autoConfigurationClasses.length > 1 && Runtime.getRuntime().availableProcessors() > 1) {
return resolveOutcomesThreaded(autoConfigurationClasses, autoConfigurationMetadata);
}
else {
Expand Down

0 comments on commit 60e7146

Please sign in to comment.