Home > Mobile > The child thread no stars. Prepare () to create a Handler is not an error
The child thread no stars. Prepare () to create a Handler is not an error
Time:10-17
This code below, in the child thread created a Handler, there is no call stars. Prepare (), however there is no error, And, the the first test log stars. MyLooper () is null, the second test log stars. MyLooper () is not null , is the new Handler () also can automatically create stars ? PS: run on the computers of the company is not an error, the same code, an error on my computer, and my computer JDK is different, but are using the android SDK to 25, the handler is android OS below, and JDK should have nothing to do?
Private void initLooperAndThread () { New Thread () { @ Override Public void the run () { The Log. I (" test ", which myLooper () + ""); MyHandler handler=new MyHandler (); The Log. I (" test ", which myLooper () + ""); } }.start(); }
The class MyHandler extends Handler { @ Override Public void handleMessage (Message MSG) { Super. HandleMessage (MSG); } } }