Benefits of using Multithreading:
1. Use multi-threading can take a long time in the program to put the task in the background to deal with, film, video download
2. Take advantage of multi-core processors to perform faster, more processes, and better user experiences for the system to run
Disadvantages of using Multithreading:
1. A large number of threads reduce the readability of the Code
2. More threads require more memory space
3. Be aware of thread safety issues when multiple threads are competing for a resource
Nsthread (two ways to create)
Pros: Nsthread than the other two lightweight
Cons: You need to manage the lifecycle of threads, thread synchronization, and the locking of data during thread synchronization has a certain overhead
Instance method -(ID) Initwithtarget: (ID) Target selector: (SEL) object: (id) argument;
Use:
Parameter resolution:
Selector: Thread execution method, this selector can only receive one parameter at most
Target:selector object sent by message
Argument: The only parameter passed to selector, or nil
class method + (void) Detachnewthreadselector: (SEL) Aselector totarget: (ID) target withobject: (id) argument;
Use:
Parameter resolution: Ibid.
How to implement multithreading in IOS Nsthread