Example usage for android.os Process myTid

List of usage examples for android.os Process myTid

Introduction

In this page you can find the example usage for android.os Process myTid.

Prototype

public static final int myTid() 

Source Link

Document

Returns the identifier of the calling thread, which be used with #setThreadPriority(int,int) .

Usage

From source file:com.android.leanlauncher.LauncherModel.java

/** Runs the specified runnable immediately if called from the worker thread, otherwise it is
 * posted on the worker thread handler. */
private static void runOnWorkerThread(Runnable r) {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        r.run();/*  www  . ja v a  2s  .  c  o m*/
    } else {
        // If we are not on the worker thread, then post to the worker handler
        sWorker.post(r);
    }
}

From source file:com.android.leanlauncher.LauncherModel.java

/** Runs the specified runnable immediately if called from the main thread, otherwise it is
 * posted on the main thread handler. */
private void runOnMainThread(Runnable r) {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        // If we are on the worker thread, post onto the main handler
        mHandler.post(r);/* ww  w.ja  v  a2  s .  c o  m*/
    } else {
        r.run();
    }
}

From source file:com.android.leanlauncher.LauncherModel.java

public void unbindItemInfosAndClearQueuedBindRunnables() {
    if (sWorkerThread.getThreadId() == Process.myTid()) {
        throw new RuntimeException("Expected unbindLauncherItemInfos() to be called from the " + "main thread");
    }//from   w  w w  .  jav a  2  s.  c  om

    // Clear any deferred bind runnables
    synchronized (mDeferredBindRunnables) {
        mDeferredBindRunnables.clear();
    }
    // Remove any queued bind runnables
    mHandler.cancelAllRunnablesOfType(MAIN_THREAD_BINDING_RUNNABLE);
    // Unbind all the workspace items
    unbindWorkspaceItemsOnMainThread();
}