當前位置: 首頁>>代碼示例>>Java>>正文


Java Process.myTid方法代碼示例

本文整理匯總了Java中android.os.Process.myTid方法的典型用法代碼示例。如果您正苦於以下問題:Java Process.myTid方法的具體用法?Java Process.myTid怎麽用?Java Process.myTid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Process的用法示例。


在下文中一共展示了Process.myTid方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCanRecordEvent

import android.os.Process; //導入方法依賴的package包/類
@SmallTest
@Feature({"Android-AppBase"})
public void testCanRecordEvent() {
    EarlyTraceEvent.enable();
    long myThreadId = Process.myTid();
    long beforeMs = SystemClock.elapsedRealtime();
    EarlyTraceEvent.begin(EVENT_NAME);
    EarlyTraceEvent.end(EVENT_NAME);
    long afterMs = SystemClock.elapsedRealtime();

    assertEquals(1, EarlyTraceEvent.sCompletedEvents.size());
    assertTrue(EarlyTraceEvent.sPendingEvents.isEmpty());
    EarlyTraceEvent.Event event = EarlyTraceEvent.sCompletedEvents.get(0);
    assertEquals(EVENT_NAME, event.mName);
    assertEquals(myThreadId, event.mThreadId);
    assertTrue(beforeMs <= event.mBeginTimeMs && event.mBeginTimeMs <= afterMs);
    assertTrue(event.mBeginTimeMs <= event.mEndTimeMs);
    assertTrue(beforeMs <= event.mEndTimeMs && event.mEndTimeMs <= afterMs);
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:20,代碼來源:EarlyTraceEventTest.java

示例2: testThreadIdIsRecorded

import android.os.Process; //導入方法依賴的package包/類
@SmallTest
@Feature({"Android-AppBase"})
public void testThreadIdIsRecorded() throws Exception {
    EarlyTraceEvent.enable();
    final long[] threadId = {0};

    Thread thread = new Thread() {
        @Override
        public void run() {
            TraceEvent.begin(EVENT_NAME);
            threadId[0] = Process.myTid();
            TraceEvent.end(EVENT_NAME);
        }
    };
    thread.start();
    thread.join();

    assertEquals(1, EarlyTraceEvent.sCompletedEvents.size());
    EarlyTraceEvent.Event event = EarlyTraceEvent.sCompletedEvents.get(0);
    assertEquals(threadId[0], event.mThreadId);
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:22,代碼來源:EarlyTraceEventTest.java

示例3: runOnMainThread

import android.os.Process; //導入方法依賴的package包/類
/** 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);
    } else {
        r.run();
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:11,代碼來源:LauncherModel.java

示例4: runOnWorkerThread

import android.os.Process; //導入方法依賴的package包/類
/** 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();
    } else {
        // If we are not on the worker thread, then post to the worker handler
        sWorker.post(r);
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:11,代碼來源:LauncherModel.java

示例5: run

import android.os.Process; //導入方法依賴的package包/類
@Override
public void run() {
    mTid = Process.myTid();
    Looper.prepare();
    synchronized (this) {
        mLooper = Looper.myLooper();
        notifyAll();
    }
    Process.setThreadPriority(mPriority);
    onLooperPrepared();
    Looper.loop();
    mTid = -1;
}
 
開發者ID:m2049r,項目名稱:xmrwallet,代碼行數:14,代碼來源:MoneroHandlerThread.java

示例6: Event

import android.os.Process; //導入方法依賴的package包/類
Event(String name) {
    mName = name;
    mThreadId = Process.myTid();
    mBeginTimeMs = SystemClock.elapsedRealtime();
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:6,代碼來源:EarlyTraceEvent.java


注:本文中的android.os.Process.myTid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。