Synchronization: Code executes sequentially, one person performs multiple tasks, and is executed in turn. A person performs only one task at a time
Async: Multiple tasks can be performed at the same time
Process: Refers to the application running in the system, each process is independent and has a separate and secure running space
Threads: A process can have multiple threads, but only one main thread. The task of the process is done within the thread.
Process, the relationship between threads and multithreading?
Process = Company Thread = Employee Multi-Threading = Boss
Multithreading can solve the problem of program blocking, but also can improve the efficiency of program execution
Automatically release Chichong meeting question code
For (int i = 0; i < 100000; ++i) {
nsstring *str = @ "Hello World";
str = [str Stringbyappendingformat:@ "-%d", I]; string concatenation
str = [str uppercasestring]; Replace a string with uppercase
}
What happens if the number of loops is too large? How to solve it?
there will be a memory overflow, Create a large number of temporary objects inside the loop without being released
Each loop will be the last object created.
For (int i = 0; i < 100000; ++i) {
@autoreleasepool {
nsstring *str = @ "Hello World";
str = [str stringbyappendingformat:@ "-%d", I];
str = [str uppercasestring];
}
}
IOS multi-threaded automatic release Chichong meet question code