is On Main Thread - Android java.lang

Android examples for java.lang:Thread

Description

is On Main Thread

Demo Code


//package com.java2s;

import android.os.Looper;

public class Main {
    /**//from   w w w.ja v a2 s . c om
     * @deprecated  use isOnUiThread
     */
    @Deprecated
    public static boolean isOnMainThread() {
        return isOnUiThread();
    }

    /**
     * Check to see whether current thread is also the UI Thread
     *
     * @return TRUE when current thread is the UI Thread
     */
    public static boolean isOnUiThread() {
        return Looper.getMainLooper().getThread() == Thread.currentThread();
    }
}

Related Tutorials