NSThread 分离新线程选择器???呃?
我正在浏览《线程编程》,我不得不说它非常好。特别是我正在查看 如何为运行循环配置基于端口的输入源。我看到这段代码
// 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码基本上告诉系统创建一个执行
[[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.