(1) First answer what is thread
1 processes to perform a task, you must have a thread. Threads are the basic execution unit of a process, and all tasks of a process (program) are executed in the thread
(2) What is multithreading
Multiple threads can be opened in 1 processes, and each thread can perform different tasks in parallel (at the same time). The role of Multithreading: Updating the Display UI interface, handling user touch events. (3) Mach is the first system to handle tasks in a multi-threaded manner, so the underlying implementation mechanism for multithreading is Mach-based threading. (4) Implementation of multithreading in the development of scenario 1 "C language POSIX interface: #include <pthread.h> 2" OC Nsthread 3 "C Language GCD interface (best performance, code more streamlined) 4" OC Nsoperation and Nsoperationqueue (based on GCD) 2. Thread Communication (1) GCD:
Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{
Download image
UIImage *image = nil;
Dispatch_async (Dispatch_get_main_queue (), ^{
Back to main thread
});
(2) Nsthread thread communication
Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{
Download image
UIImage *image = nil;
[Self performselector: @selector (settingimage:) onthread:[nsthread Mainthread] Withobject:image waituntildone:yes Modes:nil];
}
This situation also applies to communication between child threads.
(3) Nsthread of thread Communication
Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{
Download image
UIImage *image = nil;
[Self Performselectoronmainthread: @selector (settingimage:) withobject:image Waituntildone:yes];
}
3. How to solve the problem of a duplicate request of the same network address in the Network picture processing problem
Using the dictionary image address as key, the download operation is value
4. Enumerate the implementation of several multithreading in cocoa, and discuss several methods of multithreading security and how to control multithreading security?
1 "Multi-threaded solution in development
1 "C" POSIX interface: #include <pthread.h> 2 "OC nsthread 3" C GCD Interface for languages (best performance, code leaner) 4 oc nsoperation and Nsoperationqueue (based on GCD) 2 "Multithreaded security solution & nbsp 1 "Only in the main thread refresh access ui &NBSP;2" If you want to prevent resource looting, you have to use synchronize for lock protection. 3 If the asynchronous operation is to ensure the line Cheng and other issues, try to use GCD. (GCD some functions by default is safe) 5.GCD internal how to implement the 1 "iOS and OSX core is the XNU kernel (Apple Computer development operating system kernel), GCD is based on the XNU core implementation. 2 "GCD API all in Libdispatch Library 3" GCD the underlying implementation of the main: Dispatch queue and Dispatch source dispatch  ; Queue: Managing block operations Dispatch Source: Handling events (such as communication between threads) 6.GCD and nsoperationqueue 1 " GCD is a pure C language Api,nsoperationqueue is based on the GCD OC version of the package &NBSP;2 "GCD only support FIFO queue, Nsoperationqueue can easily adjust the execution sequence, You can add dependent settings for maximum concurrent quantities. 3 gcd execution speed is faster than Nsoperationqueue 4 nsoperationqueue support KVO, you can detect whether operation is executing, whether it ends, whether it is canceled or not. How do I make a selection? Tasks are not dependent on each other, choose GCD, have dependencies between tasks, or listen to the execution of tasks: Nsoperationqueue
Ios-the underlying implementation of a multi-threaded