其他分享
首页 > 其他分享> > Handler发送消息的Delay 可靠吗?

Handler发送消息的Delay 可靠吗?

作者:互联网

使用独享的Looper

   		val handlerThread=HandlerThread("test_thread")
   		handlerThread.start()
        val handler=Handler(handlerThread.looper)

HandlerThread
方便启动具有Looper的新线程。Looper可以在创建handler时使用


	//HandlerThread 的run方法
    @Override
    public void run() {
        mTid = Process.myTid();
        Looper.prepare();
        synchronized (this) {
            mLooper = Looper.myLooper();
            notifyAll();
        }
        Process.setThreadPriority(mPriority);
        onLooperPrepared();
        Looper.loop();
        mTid = -1;
    }

标签:发送,run,val,handlerThread,Delay,HandlerThread,Handler,Looper
来源: https://blog.csdn.net/huagbo/article/details/98472663