NSThread 分离新线程选择器???呃?

发布于 2024-09-29 11:51:55 字数 627 浏览 0 评论 0原文

我正在浏览《线程编程》,我不得不说它非常好。特别是我正在查看 如何为运行循环配置基于端口的输入源。我看到这段代码

// Detach the thread. Let the worker release the port.
   [NSThread detachNewThreadSelector:@selector(LaunchThreadWithPort:)
           toTarget:[MyWorkerClass class] withObject:myPort];

之前我已经理解了一切。该函数是做什么的?,什么是“LaunchThreadWithPort”,“MyWorkerClass”代表什么?

我对 @selectors 缺乏一些了解,但这不是我的主要问题。我真的不明白这个函数以及它在做什么。

感谢任何回复的人。

I was looking through the Threading Programming which I have to say it's really good. Specially I was looking on How to configure Port-based input sources for running loops. And I see this piece of code

// Detach the thread. Let the worker release the port.
   [NSThread detachNewThreadSelector:@selector(LaunchThreadWithPort:)
           toTarget:[MyWorkerClass class] withObject:myPort];

I had understood everything 'til that. What is that function doing?, What is "LaunchThreadWithPort", What does "MyWorkerClass" standFor?.

I lack a bit of knowledge on @selectors, but It's not my main question. I really didn't understand a word about that function and what is doing there.

Thanks to anyone who replies.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兔姬 2024-10-06 11:51:55

这段代码基本上告诉系统创建一个执行[[MyWorkerClass class] launchThreadWithPort: myPort]的新线程。该线程将运行直到该方法返回。

This piece of code basically tells the system to create a new thread that executes [[MyWorkerClass class] launchThreadWithPort: myPort]. The thread runs until this method returns.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文