File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
spring-context/src/main/java/org/springframework/scheduling/config Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
29
29
* @see ScheduledTaskRegistrar#scheduleCronTask(CronTask)
30
30
* @see ScheduledTaskRegistrar#scheduleFixedRateTask(FixedRateTask)
31
31
* @see ScheduledTaskRegistrar#scheduleFixedDelayTask(FixedDelayTask)
32
+ * @see ScheduledFuture
32
33
*/
33
34
public final class ScheduledTask {
34
35
@@ -54,11 +55,24 @@ public Task getTask() {
54
55
55
56
/**
56
57
* Trigger cancellation of this scheduled task.
58
+ * <p>This variant will force interruption of the task if still running.
59
+ * @see #cancel(boolean)
57
60
*/
58
61
public void cancel () {
62
+ cancel (true );
63
+ }
64
+
65
+ /**
66
+ * Trigger cancellation of this scheduled task.
67
+ * @param mayInterruptIfRunning whether to force interruption of the task
68
+ * if still running (specify {@code false} to allow the task to complete)
69
+ * @since 5.3.18
70
+ * @see ScheduledFuture#cancel(boolean)
71
+ */
72
+ public void cancel (boolean mayInterruptIfRunning ) {
59
73
ScheduledFuture <?> future = this .future ;
60
74
if (future != null ) {
61
- future .cancel (true );
75
+ future .cancel (mayInterruptIfRunning );
62
76
}
63
77
}
64
78
You can’t perform that action at this time.
0 commit comments