| | |
| | | package com.hdl.sdk.common.utils;
|
| | |
|
| | | import android.os.Handler;
|
| | | import android.os.Looper;
|
| | |
|
| | | import java.util.concurrent.ExecutorService;
|
| | | import java.util.concurrent.Executors;
|
| | | import java.util.concurrent.ScheduledExecutorService;
|
| | |
| | | */
|
| | | public class ThreadToolUtils {
|
| | |
|
| | | private final Handler uiHandler = new Handler(Looper.getMainLooper());
|
| | | // private final Handler uiHandler = new Handler(Looper.getMainLooper());
|
| | |
|
| | | //cpu 最大线程容纳量
|
| | | private final int coreSize = Runtime.getRuntime().availableProcessors() + 1;
|
| | |
| | | private ThreadToolUtils() {
|
| | | }
|
| | |
|
| | | private static class SingletonInstance {
|
| | | private static final ThreadToolUtils INSTANCE = new ThreadToolUtils();
|
| | | }
|
| | | private static final ThreadToolUtils instance = new ThreadToolUtils();
|
| | |
|
| | | public static ThreadToolUtils getInstance() {
|
| | | return SingletonInstance.INSTANCE;
|
| | | return instance;
|
| | | }
|
| | |
|
| | |
|
| | |
| | | /**
|
| | | * 切换回主线程
|
| | | */
|
| | | public void runOnUiThread(Runnable run) {
|
| | | uiHandler.post(run);
|
| | | }
|
| | |
|
| | | public void runOnUiThread(Runnable run) {
|
| | | // uiHandler.post(run);
|
| | | Thread thread = new Thread(run);
|
| | | thread.start();
|
| | | }
|
| | |
|
| | | }
|