Analysis of different queues in gcd with different functions

Source: Internet
Author: User

Two kinds of functions :

1>sync sync function ,

2>Async async function ,

Four types of queues :

1>main queue home row

2> manually created serial queues

3> Global concurrency queue

4> manually created concurrent queues

The program verifies that the two functions work together with four types of queues : A total of eight . Global concurrent queues and created concurrent queues perform the same effect, not given.

Results :

1> deadlock , the previous article has been introduced , add one thing is : The main thread in the current queue adds a task to deadlock , add to another queue does not

2> synchronization function with four queues does not open a new thread

The 3> async function does not open a new thread when mated to the home column , and other cases open the thread .

4> in the serial execution of tasks, or concurrent execution of tasks , to clarify which queue , refers to the queue after switching .

Here are eight cases of code :

The following code is the serial queue asynchronous execution, the output forgot to change:

Analysis of different queues in gcd with different functions

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.