• #### programs, processes, threads

Programs: executable applications generated from source code; Process: A running program can be viewed as a process that has all the resources it needs to run independently. Thread: a segment of code that runs independently in a program;

  • A process is made up of one or more threads. Process is only responsible for resource scheduling and allocation, thread is the real execution unit, responsible for the execution of code;

  • # # # # single thread

Each running program (process) contains at least one thread, called the main thread. The main thread is created at program startup to execute the main function;

  • A program with only one main thread is called a single-threaded program; In a single-threaded program, the main thread is responsible for executing all of the program’s code (UI presentation and refresh, network requests, local storage, and so on). This code can only be executed sequentially, not concurrently;
  • # # # # multithreaded

A program with more than one thread is called a multithreaded program; IOS allows you to create new threads, and these threads, as opposed to the main thread, are called child threads; You can open up several child threads as needed; The child thread and the main thread are independent running units, their execution does not affect each other, so they can execute concurrently;

  • #### single, multithreaded difference

Single-threaded program: only one thread, that is, the main thread, code sequential execution, prone to code blocking (page suspension); Multi-threaded program: by multiple threads, independent running between threads, can effectively avoid code blocking, and improve the running performance of the program;

  • UI additions and refreshes in iOS must be done in the main thread.
  • #####iOS several ways to achieve multiple lines
    • NSThread
    • NSOperationQueue
    • GCD