NSThread vs. NSOperationQueue vs. ??? on the iPhone

前端 未结 2 2022
一个人的身影
一个人的身影 2020-12-04 11:38

Currently I\'m using NSThread to cache images in another thread.

[NSThread detachNewThreadSelector:@selector(cacheImage:) toTarget:self withObje         


        
2条回答
  •  感情败类
    2020-12-04 12:17

    I would use NSOperationQueue. Under OS 3.2, NSOperationQueue uses threads under the hood, so the two methods should perform similarly. However, under Mac OS 10.6, NSOperationQueue uses GCD under the hood and so has the advantage of not having the overhead of separate threads. I haven't looked at the docs for OS 4, but I'd suspect it does something similar--in any case, NSOperationQueue could swap implementations if/when the performance advantages of GCD become available for the iPhone.

提交回复
热议问题