obtainmessage()是从消息池中拿来一个msg,不需要另外开辟空间,可以循环利用;
new message需要重新申请空间,效率低.
[java]
view plaincopy
//use Handler.obtainMessage(),instead of msg = new Message();
//because if there is already an Message object,that not be used by
//any one ,the system will hand use that object,so you don't have to
//create and object and allocate memory.
//it is also another example of object recycling and reusing in android.
Message msg = mHandler.obta......
阅读全文