forked from guangxush/wheel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDenyPolicy.java
More file actions
34 lines (27 loc) · 815 Bytes
/
Copy pathDenyPolicy.java
File metadata and controls
34 lines (27 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @author: guangxush
* @create: 2019/08/24
*/
@FunctionalInterface
public interface DenyPolicy {
void reject(Runnable runnable, ThreadPool threadPool);
class DiscardDenyPolicy implements DenyPolicy {
@Override
public void reject(Runnable runnable, ThreadPool threadPool) {
}
}
class AbortDenyPolicy implements DenyPolicy {
@Override
public void reject(Runnable runnable, ThreadPool threadPool) {
throw new RuntimeException("The thread " + runnable + "will be abort.");
}
}
class RunnerDenyPolicy implements DenyPolicy {
@Override
public void reject(Runnable runnable, ThreadPool threadPool) {
if (!threadPool.isShutdown()) {
runnable.run();
}
}
}
}