1. dispatch_queue_create is used to create a user thread queue. You can create two queues: Serial dispatch queue and Concurrent Dispatch queue. Serial dispatch queue is the queue waiting for execution, that is, serial execution.
Concurrent Dispatch queue does not wait for the queue currently being executed, that is, the parallel queue
1. Create serial dispatch queue
Dispatch_queue_t serialqueue = dispatch_queue_create ("hello1", null );
Because it is a serial execution, you have to create a thread to create a serial dispatch queue. If there are too many threads and too much memory is occupied, context switching will waste system resources, strictly control the number of created serial dispatch queue at one time.
This type of queue is used when multiple threads update the same data resources, causing data competition.
2. Create A Concurrent Dispatch queue
Dispatch_queue_t concurrentqueue = dispatch_queue_create ("hello2", dispatch_queue_concurrent );
If you want to execute concurrently without data competition, use Concurrent Dispatch queue. In iOS and MAC systems, xnu controls the creation of threads and ends unnecessary threads, it can well manage the threads that execute multiple parallel executions.
3. Common queue through dispatch_queue_create. Because arc is not supported, it must be released through dispatch_release. If it is to be retained, use dispatch_retain,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service