Introduction:
Concurrency occurs when two or more tasks are executed simultaneously. even if there is only one CPU, the modern operating system can execute multiple tasks at the same time. to achieve this, you need to allocate a certain time slice to each task from the CPU. for example, if you want to execute 10 characters of the same limited level within one second, the operating system will use 10 to allocate an average of 1000 milliseconds, and each task will have a CPU time of 100 milliseconds.
As technology advances, there are more than one core of the CPU, which means that the CPU has the ability to execute multiple tasks at the same time.
Grand Central Dispatch (dispatch [dispatch, dispatch]), referred to as GCD, is an underlying c api that works with block objects. the real purpose of GCD is to allocate tasks to multiple cores without worrying about which kernel to execute.
The core of GCD is the dispatch queue. you do not directly have a working relationship with the thread. You only work in the dispatch queue, assign the task to this queue, and require the queue to call your task. GCD provides several options for running a task: Synchronous asynchronous execution of delayed execution.
To start using GCD in the app, you do not need to import any special libraries into your project. GCD. All methods and data types start with the dispatch _ keyword. For example, dispatch_async allows you to assign tasks in a queue for asynchronous execution, while dispatch_after allows you to run a block after a given delay.
A Brief Introduction to concurrency