Nsthread:
Pros: Nsthread two lighter than others (Cocoa nsoperation, GCD)
Cons: You need to manage your thread's life cycle, thread synchronization. Thread synchronization has a certain overhead in locking data
Cocoa operation
Pros: No need to care about thread management, data synchronization, you can focus on what you need to do.
Cocoa operation related classes are nsoperation, Nsoperationqueue. Nsoperation is an abstract class that uses its subclasses to implement it or to use the two subclasses it defines: Nsinvocationoperation and nsblockoperation. Creates an object of the Nsoperation subclass and adds the object to the Nsoperationqueue queue for execution.
GCD
Grand Central Dispatch (GCD) is a solution for multi-core programming developed by Apple. Can only be used after the iOS4.0 has started. GCD is an efficient and powerful alternative to technologies such as Nsthread, Nsoperationqueue, and Nsinvocationoperation. Now the iOS system has been upgraded to 6, so don't worry about the technology being used.
1. Nsthread has two direct creation methods:
-(ID) Initwithtarget: (ID) Target selector: (SEL) Selector object: (ID) argument
+ (void) Detachnewthreadselector: (SEL) Aselector totarget: (ID) atarget withobject: (ID) anargument
The first is an instance method, the second is a class method
2. The meaning of the parameter:
Selector: The method that the thread executes, this selector can only have one parameter, and cannot have the return value.
Target:selector object sent by message
Argument: The only parameter transmitted to target, or nil
The first way is to create the thread directly and start running the thread, the second way is to create the thread object before running the thread operation, you can set the thread's priority and so on thread information before running the thread operation
Ios-nsthread use