LightTaskUtils概述
LightTaskUtils截图
LightTaskUtils源码
版权声明 本文原创作者:谷哥的小弟
作者博客地址:http://blog.csdn.net/lfdfhl
LightTaskUtils概述LightTaskUtils是一个轻量级的线程管理工具。
LightTaskUtils截图LightTaskUtils截图如下:
LightTaskUtils源码LightTaskUtils源码如下:
import android.os.HandlerThread;
import android.os.Handler;
public class LightTaskUtils {
private Handler mHandler;
private HandlerThread mHandlerThread;
public LightTaskUtils() {
mHandlerThread = new HandlerThread("LightTaskThread");
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
}
public void post(Runnable runnable) {
if (mHandler != null) {
mHandler.post(runnable);
}
}
public void postAtFrontOfQueue(Runnable runnable) {
if (mHandler != null) {
mHandler.postAtFrontOfQueue(runnable);
}
}
public void postDelayed(Runnable runnable, long delay) {
if (mHandler != null) {
mHandler.postDelayed(runnable, delay);
}
}
public void postAtTime(Runnable runnable, long time) {
if (mHandler != null) {
mHandler.postAtTime(runnable, time);
}
}
public void removePost() {
if (mHandlerThread != null) {
mHandlerThread.quit();
mHandlerThread = null;
}
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
mHandler = null;
}
}
}
到此这篇关于Android项目开发常用工具类LightTaskUtils的文章就介绍到这了,更多相关android开发工具类LightTaskUtils内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!