有个类继承自 Thread
class MyThread extends Thread{
@Override
public void run(){
while(online){
doSomehing();
}
}
};
public void finishThread(){
online = false;
}
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void printLog(DeviceLog deviceLog){
writeLog(deviceLog);
}
对于这样一个线程类,在运行过程中设备其他 Activity 有代码
EventBus.getDefault().post(new DeviceLog());
然后此时线程开始执行 writeLog()函数,假设改函数需要执行比较长的时间,然后在这段时间内,调用了线程的 finishThread()函数,此时线程 run()函数结束,但 wrtiLog()函数尚未执行完成,那这种情况下,能否保证 wrtiLog()函数执行完?