原文:https://blog.csdn.net/d276031034/article/details/54617094
这段代码在处理耗时操作时能用到,同时耗时操作处理完成后,还会有处理结果的通知,挺好用的。
try {
final Handler handler = new Handler();
final Runnable callBack = new Runnable() {
public void run() {
try {
//线程结束,处理
} catch (Exception ex) {
ex.getStackTrace();
}
}
};
final Thread thread = new Thread() {
@Override
public void run() {
try {
//耗时操作
} catch (Exception ex) {
}
handler.post(callBack);
}
};
thread.start();
} catch (Exception ex) {
}