Android Looper函数

SunnyTime 发布于 2015/03/03 16:37
阅读 73
收藏 0
package android.os;

import android.util.Log;
import android.util.Printer;
import android.util.PrefixPrinter;
import dalvik.system.VMDebug; 
import android.os.MessageMonitorLogger;
import com.mediatek.common.msgmonitorservice.IMessageLogger;
import android.os.Process;
import java.util.Iterator;

public final class Looper {
    private static final String TAG = "Looper";
    static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
    private static Looper sMainLooper;  // guarded by Looper.class

    final MessageQueue mQueue;
    final Thread mThread;

    private Printer mLogging;
    private Printer mMsgMonitorLogging;
    private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE) || "userdebug".equals(Build.TYPE);

     /** Initialize the current thread as a looper.
      * This gives you a chance to create handlers that then reference
      * this looper, before actually starting the loop. Be sure to call
      * {@link  #loop()} after calling this method, and end it by calling
      * {@link #quit()}.
    public static void prepare() {        prepare(true);

    private static void prepare(boolean quitAllowed) {
        if (sThreadLocal.get() != null) {
            throw new RuntimeException("Only one Looper may be created per thread");