hch
2024-04-01 2af4b92997143d33f41d15160f2a152f334ea59b
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);
    }
 
}