Skip to content

Commit c5aa783

Browse files
committed
Polishing
(cherry picked from commit abbea39)
1 parent 14c8c91 commit c5aa783

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

spring-context/src/main/java/org/springframework/scheduling/annotation/SchedulingConfigurer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,10 +40,10 @@
4040
public interface SchedulingConfigurer {
4141

4242
/**
43-
* Callback allowing a {@link org.springframework.scheduling.TaskScheduler
44-
* TaskScheduler} and specific {@link org.springframework.scheduling.config.Task Task}
45-
* instances to be registered against the given the {@link ScheduledTaskRegistrar}.
46-
* @param taskRegistrar the registrar to be configured.
43+
* Callback allowing a {@link org.springframework.scheduling.TaskScheduler}
44+
* and specific {@link org.springframework.scheduling.config.Task} instances
45+
* to be registered against the given the {@link ScheduledTaskRegistrar}.
46+
* @param taskRegistrar the registrar to be configured
4747
*/
4848
void configureTasks(ScheduledTaskRegistrar taskRegistrar);
4949

spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@
3333
* {@link TaskExecutor} implementation that fires up a new Thread for each task,
3434
* executing it asynchronously.
3535
*
36-
* <p>Supports limiting concurrent threads through the "concurrencyLimit"
37-
* bean property. By default, the number of concurrent threads is unlimited.
36+
* <p>Supports limiting concurrent threads through {@link #setConcurrencyLimit}.
37+
* By default, the number of concurrent task executions is unlimited.
3838
*
3939
* <p><b>NOTE: This implementation does not reuse threads!</b> Consider a
4040
* thread-pooling TaskExecutor implementation instead, in particular for
@@ -133,33 +133,31 @@ public final ThreadFactory getThreadFactory() {
133133
* have to cast it and call {@code Future#get} to evaluate exceptions.
134134
* @since 4.3
135135
*/
136-
public final void setTaskDecorator(TaskDecorator taskDecorator) {
136+
public void setTaskDecorator(TaskDecorator taskDecorator) {
137137
this.taskDecorator = taskDecorator;
138138
}
139139

140140
/**
141-
* Set the maximum number of parallel accesses allowed.
142-
* -1 indicates no concurrency limit at all.
143-
* <p>In principle, this limit can be changed at runtime,
144-
* although it is generally designed as a config time setting.
145-
* NOTE: Do not switch between -1 and any concrete limit at runtime,
146-
* as this will lead to inconsistent concurrency counts: A limit
147-
* of -1 effectively turns off concurrency counting completely.
141+
* Set the maximum number of parallel task executions allowed.
142+
* The default of -1 indicates no concurrency limit at all.
143+
* <p>This is the equivalent of a maximum pool size in a thread pool,
144+
* preventing temporary overload of the thread management system.
148145
* @see #UNBOUNDED_CONCURRENCY
146+
* @see org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor#setMaxPoolSize
149147
*/
150148
public void setConcurrencyLimit(int concurrencyLimit) {
151149
this.concurrencyThrottle.setConcurrencyLimit(concurrencyLimit);
152150
}
153151

154152
/**
155-
* Return the maximum number of parallel accesses allowed.
153+
* Return the maximum number of parallel task executions allowed.
156154
*/
157155
public final int getConcurrencyLimit() {
158156
return this.concurrencyThrottle.getConcurrencyLimit();
159157
}
160158

161159
/**
162-
* Return whether this throttle is currently active.
160+
* Return whether the concurrency throttle is currently active.
163161
* @return {@code true} if the concurrency limit for this instance is active
164162
* @see #getConcurrencyLimit()
165163
* @see #setConcurrencyLimit

spring-core/src/main/java/org/springframework/util/ConcurrencyThrottleSupport.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,7 +69,7 @@ public abstract class ConcurrencyThrottleSupport implements Serializable {
6969

7070
/**
7171
* Set the maximum number of concurrent access attempts allowed.
72-
* -1 indicates unbounded concurrency.
72+
* The default of -1 indicates no concurrency limit at all.
7373
* <p>In principle, this limit can be changed at runtime,
7474
* although it is generally designed as a config time setting.
7575
* <p>NOTE: Do not switch between -1 and any concrete limit at runtime,
@@ -143,9 +143,10 @@ protected void beforeAccess() {
143143
*/
144144
protected void afterAccess() {
145145
if (this.concurrencyLimit >= 0) {
146+
boolean debug = logger.isDebugEnabled();
146147
synchronized (this.monitor) {
147148
this.concurrencyCount--;
148-
if (logger.isDebugEnabled()) {
149+
if (debug) {
149150
logger.debug("Returning from throttle at concurrency count " + this.concurrencyCount);
150151
}
151152
this.monitor.notify();

0 commit comments

Comments
 (0)