线程间通信的方式比performSelector更简单:onThread:withObject

时间:2012-11-24 08:34:41

标签: objective-c multithreading real-time nsthread

我正在按照Matt Ghallagher performSelector:onThread:withObject:waitUntilDone:的建议测试tutorial进行线程间通信。事实证明,对于实时音频应用来说,它非常慢,而且几乎no good。有什么建议?

1 个答案:

答案 0 :(得分:0)

在主线上:

AnyClass myObject;

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
   // do asynchronous work
   // environment objects and variables will be available
   [myObject doSomething];
});

它真的没有比那更简单......