【发布时间】:2013-03-02 08:02:39
【问题描述】:
如何检索线程的“名称”?
(请参阅应用程序暂停的 xcode 图片,其中,我所说的“名称”以黄色突出显示,“com.apple.coremedia.player.async”......我可以检索正在运行的线程,并拥有尝试了以下,没有运气
mach_msg_type_number_t count, i;
thread_act_array_t list;
task_threads(mach_task_self(), &list, &count);
for (i = 0; i < count; i++) {
if (list[i] == mach_thread_self()) continue;
char theName[16];
memset(theName, 0x00, sizeof(theName));
pthread_getname_np(list[i], theName);
printf("The thread name is %s.\n", theName);
}
注意:我不是在询问当前线程的线程名称。我有兴趣从一组正在运行的线程中获取线程名称(参见上面的示例)。所以关于 [NSThread currentThread] 的解决方案不会工作
【问题讨论】:
-
我相信 PLCrashReporter 能够做到这一点,请尝试查看他们的页面。
-
你到底想通过这样做来完成什么?
-
打印出每个正在运行的线程的线程名
标签: iphone ios objective-c c multithreading