the obtainMessage and post method overloads val message = handler.obtainMessage(LOAD_SUCCESS, result) message.sendToTarget() or mainThreadHandler.post { // some ui thread related code }
through a Handler • Message is a public class but should not be instantiated: there’s a pool of recycled message objects (Message.obtain, Handler.obtainMessage)