-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadPool.java
More file actions
executable file
·40 lines (33 loc) · 850 Bytes
/
ThreadPool.java
File metadata and controls
executable file
·40 lines (33 loc) · 850 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
35
36
37
38
39
40
/*** In The Name of Allah ***/
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ThreadPool {
private static ExecutorService executor;
/**
* Initializes a new CachedThreadPool.
* @see Executors#newCachedThreadPool()
*/
public static void init() {
executor = Executors.newCachedThreadPool();
}
/**
* {@link ExecutorService#execute(Runnable)}
*/
public static void execute(Runnable r) {
if (executor == null)
init();
executor.execute(r);
}
/**
* {@link ExecutorService#shutdown()}
*/
public static void shutdown() {
executor.shutdown();
}
/**
* {@link ExecutorService#shutdownNow()}
*/
public static void shutdownNow() {
executor.shutdownNow();
}
}