Operation queues中多线程的支持

Operation queues usually provide the threads used to run their operations. In OS X v10.6 and later, operation queues use the libdispatch library (also known as Grand Central Dispatch) to initiate the execution of their operations. As a result, operations are always executed on a separate thread, regardless of whether they are designated as concurrent or non-concurrent operations. In OS X v10.5, however, operations are executed on separate threads only if their isConcurrent method returns NO. If that method returns YES, the operation object is expected to create its own thread (or start some asynchronous operation); the queue does not provide a thread for it.

OperationQueues通常提供了运行operationsd的线程。在OS X v10.6之后,operationsQueue使用libdispatch库(GCD)来初始化这些operations的执行逻辑。所以,operations通常是在一个独立的thread中执行,不管它是执行并发还是不支持并发。但是,在OS X v10.5系统中,operations只有在不支持并发的的情况下才使用同一个Thread执行任务,如果isConcurrent返回YES,那么operation object会被安排在各自不同的线程中去执行,operation queue不再提供执行的线程环境。

posted @ 2013-05-01 19:46  Eric.wei  阅读(150)  评论(0编辑  收藏  举报