@@ -53,7 +53,7 @@ public enum ExecutorType {
53
53
*/
54
54
public static Schedulers newDefault () {
55
55
createSingleton ();
56
- instance .increaseNoOfSchedullers ();
56
+ Schedulers .increaseNoOfSchedullers ();
57
57
instance .setCurrentScheduler (new ConcurrentTaskScheduler ());
58
58
return instance ;
59
59
}
@@ -67,7 +67,7 @@ public static Schedulers newDefault() {
67
67
*/
68
68
public static Schedulers newThreadPoolScheduler (int poolSize ) {
69
69
createSingleton ();
70
- instance .increaseNoOfSchedullers ();
70
+ Schedulers .increaseNoOfSchedullers ();
71
71
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler ();
72
72
CustomizableThreadFactory factory = new CustomizableThreadFactory ();
73
73
scheduler .initializeExecutor (factory , new RejectedExecutionHandler () {
@@ -99,8 +99,8 @@ public static Schedulers stop(String schedulerId) {
99
99
throw new IllegalStateException ("No schedulers match with given id." );
100
100
}
101
101
future .cancel (true );
102
- instance .decreaseNoOfSchedullers ();
103
- instance .decreaseNoOfRunningSchedullers ();
102
+ Schedulers .decreaseNoOfSchedullers ();
103
+ Schedulers .decreaseNoOfRunningSchedullers ();
104
104
105
105
return instance ;
106
106
}
@@ -119,8 +119,8 @@ public static Schedulers stopAll() {
119
119
for (Entry <String , ScheduledFuture <?>> entry : instance .runningSchedullers .entrySet ()) {
120
120
ScheduledFuture <?> future = entry .getValue ();
121
121
future .cancel (true );
122
- instance .decreaseNoOfSchedullers ();
123
- instance .decreaseNoOfRunningSchedullers ();
122
+ Schedulers .decreaseNoOfSchedullers ();
123
+ Schedulers .decreaseNoOfRunningSchedullers ();
124
124
}
125
125
126
126
return instance ;
@@ -138,9 +138,9 @@ public String schedule(TriggerTask task) {
138
138
throw new IllegalStateException ("New scheduler should be crea" );
139
139
}
140
140
ScheduledFuture <?> future = getCurrentScheduler ().schedule (task .getRunnable (), task .getTrigger ());
141
- String id = getUUID ();
141
+ String id = Schedulers . getUUID ();
142
142
runningSchedullers .put (id , future );
143
- increaseNoOfRunningSchedullers ();
143
+ Schedulers . increaseNoOfRunningSchedullers ();
144
144
setCurrentScheduler (null );
145
145
return id ;
146
146
}
@@ -154,9 +154,9 @@ public String schedule(TriggerTask task) {
154
154
*/
155
155
public String schedule (Trigger trigger , Runnable task ) {
156
156
ScheduledFuture <?> future = getCurrentScheduler ().schedule (task , trigger );
157
- String id = getUUID ();
157
+ String id = Schedulers . getUUID ();
158
158
runningSchedullers .put (id , future );
159
- increaseNoOfRunningSchedullers ();
159
+ Schedulers . increaseNoOfRunningSchedullers ();
160
160
setCurrentScheduler (null );
161
161
return id ;
162
162
}
@@ -173,28 +173,28 @@ public static TaskRegistrar taskRegistry() {
173
173
/**
174
174
* Increase no of schedullers.
175
175
*/
176
- private synchronized void increaseNoOfSchedullers () {
176
+ private static synchronized void increaseNoOfSchedullers () {
177
177
noOfSchedullers ++;
178
178
}
179
179
180
180
/**
181
181
* Increase no of running schedullers.
182
182
*/
183
- private synchronized void increaseNoOfRunningSchedullers () {
183
+ private static synchronized void increaseNoOfRunningSchedullers () {
184
184
noOfRunningSchedullers ++;
185
185
}
186
186
187
187
/**
188
188
* Decrease no of schedullers.
189
189
*/
190
- private synchronized void decreaseNoOfSchedullers () {
190
+ private static synchronized void decreaseNoOfSchedullers () {
191
191
noOfSchedullers --;
192
192
}
193
193
194
194
/**
195
195
* Decrease no of running schedullers.
196
196
*/
197
- private synchronized void decreaseNoOfRunningSchedullers () {
197
+ private static synchronized void decreaseNoOfRunningSchedullers () {
198
198
noOfRunningSchedullers --;
199
199
}
200
200
@@ -203,7 +203,7 @@ private synchronized void decreaseNoOfRunningSchedullers() {
203
203
*
204
204
* @return the uuid
205
205
*/
206
- private synchronized String getUUID () {
206
+ private static synchronized String getUUID () {
207
207
return String .valueOf (UUID .randomUUID ().getLeastSignificantBits ());
208
208
}
209
209
0 commit comments