po [NSThread 当前线程] [英] po [NSThread currentThread]

查看:65
本文介绍了po [NSThread 当前线程]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行 po [NSThread currentThread] 时,我得到了

When I do po [NSThread currentThread], I got

{name = (null), num = 4}

{name = (null), num = 4}

当我向左看时,我看到:

When I look to the left I see:

看起来是线程编号 6,而不是 4.此外,我们还需要调用哪些属性来获取该线程编号?

Looks like it's Thread number 6, not 4. Also what properties do we need to call to get that thread numbers anyway?

[NSThread currentThread].number?虽然不存在.

[NSThread currentThread].number? Doesn't exist though.

推荐答案

线程编号几乎毫无意义.

Thread numbers are meaningless, pretty much.

不过,线程实例是每个线程的单例.巧合的是,您可以使用 NSThread 的地址.更好的是,深入到 mach_* API 并从该 API 中获取线程 ID.

The thread instance, though, is a singleton per thread. You could use the NSThread's address, by coincidence. Better, still, would be to dip down to the mach_* API and grab the thread ID from that API.

[NSThread currentThread] 与您将获得的数字一样独特.如果线程终止,然后创建了一个新线程,您可能会看到出售的相同地址.mach API 将提供一些非常独特的东西.

[NSThread currentThread] is about as unique of a number as you'll get. If the thread terminates and then a new thread is created, you might see the same address vended. The mach APIs will vend something just about as unique, really.

你想做什么?

这篇关于po [NSThread 当前线程]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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