在system.log中,我可以看到我的过程:
thread 515376 caught burning CPU! It used more than 50% CPU
我使用多个线程,所以我尝试在线程使用的可运行方法中打印线程ID,如下所示:
void* runnable1(void* ptr)
{
pthread_t tid = pthread_self();
printf("HELLO from thread runnable1 with id : %ld\n", tid);
...
}
但是我得到这样的ID:
HELLO from thread runnable1 with id : 4488212480
与system.log中的非常不同。
问题是,如何获得线程ID出现在system.log中的方式?
尝试:
uint64_t tid;
pthread_threadid_np(NULL, &tid);
printf("HELLO from thread runnable1 with id : %ld\n", tid);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句