lwb
2021-03-23 d8fc939d4e6e0a8748a5a87e32c2d0bf219d0a5f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.secondworld.sdk;
 
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
 
//耗时任务操作
public class AsyncTaskOperator {
 
    public static AsyncTaskOperator I = new AsyncTaskOperator();
 
    private ExecutorService cachedThreadPool;
 
    private ExecutorService getCachedThreadPool() {
        if (cachedThreadPool == null) {
            cachedThreadPool = Executors.newCachedThreadPool();
        }
        return cachedThreadPool;
    }
 
    public void run(Runnable runnable) {
        getCachedThreadPool().execute(runnable);
    }
 
}