I’m trying to understand Objective C code and I’m stuck in this line
Code:
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
I understand that this line constructs a new instance of a class NSOperationQueue. But what does this instance of NSOperationQueue do? Can anyone explain that to me? As I am more familiar with Java, it would be very helpful if someone could suggest me an equivalent piece of code in Java.
The
NSOperationQueueimplements basically the same functionality as you can get from aThreadPoolExecutorplus aBlockingQueuein Java.That is it takes a collection of
NSOperations (approximate toRunnabless in Java) and executes then asynchronously.With the added bonus that the operation queue tunes itself to the current run-time conditions.