在使用HandlerThread时将处理哪个线程消息?

时间:2014-03-21 03:27:44

标签: android handler

下面用UI线程编写的代码

Handler handler

 HandlerThread thread = new HandlerThread("SquareHandlerThread");
        thread.start(); // starts the thread.
        Looper looper = thread.getLooper();

//在UI线程中编写的代码下面并使用HandlerThread的looper

        handler = new Handler(looper)
       {

        public void handleMessage(Message msg)
        {
           // do something
         }
      };

//我使用的其他一些线程我可以访问上面创建的处理程序的引用

hadler.sendMessage(messageObject)

现在的问题是在HandlerThread创建的mainthread或单独的线程中处理哪些线程消息(它为处理程序提供了looper)?

0 个答案:

没有答案