. Grand Central Dispatch (GCD) dispatch queues are useful tool for performing tasks asynchronously or synchronously depend on how it is called. You can use dispatch queues to handle task better than threads .A dispatch queue manages the task automatically .All dispatch queues are FIFO (fist-in-first-out) order. So the tasks added to a queue are executed in a same order as they were added. The advantage is the simplicity of the work-queue programming model. In threads you have to write the code for work as well as management of threads but dispatch queue let you focus on what you want to perform without taking care of threads creation and their management. Types of dispatch queues- 1. Serial Queue – Serial queues is also called private dispatch queues .It execute one task at a time in order the task are added to the queue. Serial queues are specially used for synchronize access to a specific resource. 2. Concurrent Queue- Concurrent queues is also known as global dispatch queue . It execute one or more tasks concurrently but tasks are started executing in same order as they were added to the queue. The executing tasks run on distinct threads that are handled by dispatch queue. you can create concurrent dispatch queues yourself by specifying DISPATCH_QUEUE_CONCURRENT as the queue type. 3. Main dispatch queue- The main dispatch queue is a globally available serial queue that executes tasks on the application’s main thread and you do not need to create the main dispatch queue. Main dispatch queue is used for performing UI related tasks for task related to processing or other background task perform it using other thread.
Can you answer this question?
Write Answer1 Answers