如何获得Android的线程ID? [英] How to get Android Thread ID?

查看:1380
本文介绍了如何获得Android的线程ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这code抛出给定的主题不存在当我尝试使用它在一个线程异常:

  android.os.Process.getThreadPriority((INT)Thread.currentThread()的getId()));
 

同上,如果我尝试使用Process.setThreadPriority,使用java类线程ID。我也注意到,这种不匹配在调试器中显示的线程ID。我如何获取Android特定线程ID,才能使用此API?

解决方案

  android.os.Process.getThreadPriority(android.os.Process.myTid());
 

有关进一步参考

<一个href="http://developer.android.com/reference/android/os/Process.html#myTid()">http://developer.android.com/reference/android/os/Process.html#myTid()

This code throws a "Given thread does not exist" exception when I try to use it in a thread:

android.os.Process.getThreadPriority((int) Thread.currentThread().getId()));

Ditto if I try to use Process.setThreadPriority, using the java class Thread id. I've also noticed that this does not match the thread id displayed in the debugger. How do I get the Android specific thread id, in order to use this API?

解决方案

android.os.Process.getThreadPriority(android.os.Process.myTid());

For further reference

http://developer.android.com/reference/android/os/Process.html#myTid()

这篇关于如何获得Android的线程ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆