当前位置: 首页>>代码示例>>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;未经允许,请勿转载。