NSOperation 全部运行

发布于 2024-12-07 08:34:34 字数 200 浏览 5 评论 0原文

我的程序在程序员看不到的地方崩溃了。它可能与内存管理有关,但它肯定与多个线程和超过 200 个通知观察者有关...

我想知道这种启动派生 NSOperation 对象是否会确保所有操作都被执行作为一个线程上的正常执行?

[operation start];
[operation waitUntilFinished];

I have program that is crashing somewhere not really visible to programmer. It may have something to do with memory management but it definitively has something to do with multiple threads and more than 200 notification observers...

I would like to know if that kind of starting derived NSOperation object would ensure that all operations are being executed consequently as normal execution on one thread?

[operation start];
[operation waitUntilFinished];

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

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

发布评论

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

评论(2

Spring初心 2024-12-14 08:34:34

我认为您正在寻找的是 operationQueue.maxConcurrentOperationCount = 1 ,然后将所有操作添加到 NSOperationQueue 中。它们将被串行地、一个接一个地执行。

I think what you're looking for is operationQueue.maxConcurrentOperationCount = 1 and then add all your operations to the NSOperationQueue. They will be executed serially, one after another.

夜司空 2024-12-14 08:34:34

不,它启动操作,然后阻塞调用线程直到完成。

No, it starts the operation and then blocks the calling thread until it is done.

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