OGeek|极客世界-中国程序员成长平台

标题: ios - 在调试导航器或其他工具中显示线程标签 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 23:44
标题: ios - 在调试导航器或其他工具中显示线程标签

在我的项目中有很多后台线程。我想检查每个线程是否在没有崩溃的情况下工作并在需要时消失。因为我的程序使用了 26% 的 CPU。所以我标记了每个后台线程:

let myQueue = DispatchQueue(label: "myQ", qos: .background, target: nil)

myQueue.async {
     someFunc()
}

但在 Xcode Debug navigator 中,我看到了未命名的线程:

enter image description here

编辑

嗯,我找到了办法:

DispatchQueue.global(qos: .background).async {
                Thread.current.name = "my thread"
                somefunc()
            }

但是为什么我们需要 DispatchQueue 中的标签呢?



Best Answer-推荐答案


嗯,我找到了办法:

DispatchQueue.global(qos: .background).async {
                Thread.current.name = "my thread"
                somefunc()
            }

但是为什么我们需要 DispatchQueue 中的标签呢?

关于ios - 在调试导航器或其他工具中显示线程标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41596376/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4