lwb
2021-03-10 947e8d781f0dedbcf12e3f70ee68d462362939bf
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);
    }
 
}