日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android adm查看进程,基于android studio 的ADM对卡顿,耗时方法的检测

發布時間:2025/3/19 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android adm查看进程,基于android studio 的ADM对卡顿,耗时方法的检测 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Message next() {

// 當消息循環已經退出或被釋放的時候,直接返回null

// 如果應用程序在退出后嘗試重新啟動一個looper,就可能會發生這種情況

final long ptr = mPtr;

if (ptr == 0) {

return null;

}

int pendingIdleHandlerCount = -1; // -1 only during first iteration

int nextPollTimeoutMillis = 0;

for (;;) {//死循環

//將當前線程中的任何阻塞的binder命令刷新到cpu中執行,在執行可能導致長時間阻塞的操作前調用是非常有用的,可以確保任何掛起的對象引用被釋放,防止進程持有一個對象的時間超過它所需要的

if (nextPollTimeoutMillis != 0) {

Binder.flushPendingCommands();

}

//消息死循環不會崩潰的原因

nativePollOnce(ptr, nextPollTimeoutMillis);

//同步代碼塊

synchronized (this) {

// 嘗試檢索下一條信息,如果有就返回

final long now = SystemClock.uptimeMillis();

Message prevMsg = null;

Message msg = mMessages;

if (msg != null && msg.target == null) {

// Stalled by a barrier. 在消息隊列中查找下一個異步消息

do {

prevMsg = msg;

msg = msg.next;

} while (msg != null && !msg.isAsynchronous());

}

if (msg != null) {

if (now < msg.when) {

//如果下一條消息尚未準備好。設置超時喚醒

nextPollTimeoutMillis = (int) Math.min(msg.when - now, Integer.MAX_VALUE);

} else {

// 如果準備好了就獲取消息.

mBlocked = false;

if (prevMsg != null) {

prevMsg.next = msg.next;

} else {

mMessages = msg.next;

}

msg.next = null;

if (DEBUG) Log.v(TAG, "Returning message: " + msg);

msg.markInUse();

return msg;

}

} else {

// 沒有異步消息了

nextPollTimeoutMillis = -1;

}

// Process the quit message now that all pending messages have been handled.

if (mQuitting) {

dispose();

return null;

}

// 如果第一次空閑,則獲取可運行消息數

// 空閑消息只會在消息隊列為空或者隊列第一個消息將要被處理時處理

if (pendingIdleHandlerCount < 0

&& (mMessages == null || now < mMessages.when)) {

pendingIdleHandlerCount = mIdleHandlers.size();

}

if (pendingIdleHandlerCount <= 0) {

// No idle handlers to run. Loop and wait some more.

mBlocked = true;

continue;

}

if (mPendingIdleHandlers == null) {

//容量只有四個

mPendingIdleHandlers = new IdleHandler[Math.max(pendingIdleHandlerCount, 4)];

}

mPendingIdleHandlers = mIdleHandlers.toArray(mPendingIdleHandlers);

}

// Run the idle handlers.

//只有在第一次迭代中才到達這個代碼塊

for (int i = 0; i < pendingIdleHandlerCount; i++) {

final IdleHandler idler = mPendingIdleHandlers[i];

mPendingIdleHandlers[i] = null; // release the reference to the handler

boolean keep = false;

try {

keep = idler.queueIdle();

} catch (Throwable t) {

Log.wtf(TAG, "IdleHandler threw exception", t);

}

if (!keep) {

synchronized (this) {

//當返回值keep為false時,從空閑列表中移除

mIdleHandlers.remove(idler);

}

}

}

// 保證了空閑列表中的消息只處理一次.

pendingIdleHandlerCount = 0;

// 在調用空閑處理程序時,可能已經傳遞了一個新消息,因此可以返回并再次查找掛起的消息,而不必等待

nextPollTimeoutMillis = 0;

}

}

總結

以上是生活随笔為你收集整理的android adm查看进程,基于android studio 的ADM对卡顿,耗时方法的检测的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。