Message message = Message.obtain();
message.what =10;
handler.sendMessage(message);//sendMessage 点击去查看我们可以定位到这里privatebooleanenqueueMessage(@NonNull MessageQueue queue,@NonNull Message msg,long uptimeMillis){
msg.target =this;
msg.workSourceUid = ThreadLocalWorkSource.getUid();if(mAsynchronous){
msg.setAsynchronous(true);}return queue.enqueueMessage(msg, uptimeMillis);}//我们只看return的部分 MessageQueue 执行的时消息队列插入消息的方法//在MessageQueue里面booleanenqueueMessage(Message msg,long when){synchronized(this){
msg.markInUse();
msg.when = when;
Message p = mMessages;boolean needWake;if(p == null || when ==0|| when < p.when){// New head, wake up the event queue if blocked.
msg.next = p;
mMessages = msg;
needWake = mBlocked;}else{// Inserted within the middle of the queue. Usually we don't have to wake// up the event queue unless there is a barrier at the head of the queue// and the message is the earliest asynchronous message in the queue.
needWake = mBlocked && p.target == null && msg.isAsynchronous();
Message prev;for(;;){
prev = p;
p = p.next;if(p == null || when < p.when){break;}if(needWake && p.isAsynchronous()){
needWake =false;}}
msg.next = p;// invariant: p == prev.next
prev.next = msg;}// We can assume mPtr != 0 because mQuitting is false.if(needWake){nativeWake(mPtr);}}returntrue;}