get Thread Info as String - Android Android OS

Android examples for Android OS:Thread

Description

get Thread Info as String

Demo Code


//package com.java2s;
import android.os.Looper;

public class Main {
    public static String getThreadInfo() {

        String textMainThread = Thread.currentThread().getId() == Looper
                .getMainLooper().getThread().getId() ? " - the MAIN thread!"
                : " - NOT the MAIN thread!";

        return "Thread " + Thread.currentThread().getId() + textMainThread;
    }//  ww  w.j  a  v a  2  s.c o  m
}

Related Tutorials