1

I have a strange problem. There is code execute interrupted in a handlerthread. The enviroment is an Android system's car machine. In the last year's test time of this project, I have encountered the problem more than five times.But see the log,I can't get the reason of this problem。

Who knows the cause of this problem? Is it caused by JVM or Android handlerthread or CPU and Why?

Because there the project code is comple , the problem simple codes and phenomenon are as follows:

 //init logic code
 HandlerThread ht = new ThandlerThread("sample"); 
 ht.start();
 Handler handler = new Handler(ht.getLooper()){
    @Override
    public void handleMessage(Message msg) {
        switch (msg.what){
        case 1:
           test();
        break;
    }
 };
 //send message logic
 Message message = handler .obtainMessage();
 message.what= 1;
 handler .sendMessage(message);
 //test method impl
 public void test(){
    Log.d("test","execute test start");
    Log.d("test","before a");
    simpleA();//some operation very simple and you can know this method whether execute by log and 
    app’s ui state
    //some log
    Log.d("test","after a");
    Log.d("test","before b");
    simpleB()
    Log.d("test","after B");

    Log.d("test","test log1");
    Log.d("test","test log2");
    Log.d("test","execute test end");
 }

Nomally and most of time,the test method can excute well easy.Some times when the test method executed,may "execute test start" log print but after this code's logic not execute,or "test log2" log print but "execute test end",or "before b" print but simpleB method and behind code not execute.This is not log miss because you can analyse the code execute is stay the same with ui and data. The cpu info is Freescale Semiconductor IMX6QP

Bruce
  • 11
  • 1

0 Answers0