gpt4 book ai didi

objective-c - 调用 [NSScreen mainScreen] 时的额外线程

转载 作者:行者123 更新时间:2023-12-03 16:37:11 24 4
gpt4 key购买 nike

这是我在调试应用程序时观察到的情况。我的应用程序本质上是一个单线程应用程序。

应用程序最初只有一个线程。

线程 1:队列:com.apple.main-thread。

在我的应用程序中,当点击以下代码时

 NSScreen * mainscreen = [NSScreen mainScreen];

然后创建以下线程。

  1. 线程 3:队列:com.apple.libdispatch-manager
  2. 主题 5
  3. 线程 6
  4. 主题 7

线程3的调用堆栈是凯文64_dispatch_mgr_thread

线程5、6和7的调用堆栈是__workq_kernreturnstart_wqthread

为什么线程3、5、6和7突然出现在[NSScreen mainScreen]上?

加载应用程序后,当我破坏它时,它会显示线程 16 CVDisplayLink。什么是 CVDisplayLink?

我使用 Mac OS X Mavericks Preview 和 Xcode 5 进行调试。

最佳答案

Mac Developer Library 中所述:

A Core Video display link provides a separate high-priority thread to notify your application when a given display will need each frame. You can use a display link to easily synchronize with the refresh rate of a display. The display link API uses the Core Foundation class system internally to provide reference counting behavior and other useful properties.

关于objective-c - 调用 [NSScreen mainScreen] 时的额外线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17522972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com