What's the difference between the "global queue" and the "main queue" in GCD?

Among some other ways, there are these two ways to get queues in GCD:

dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_get_main_queue();

If I'm not completely wrong, the "main queue" is executing on the main thread and is good for "callback" blocks which execute UI work.

Does this mean a "global queue" is one that runs on a background thread?

The main queue does indeed run on the main thread like you say.

The global queues are concurrent queues and from the main page for dispatch_get_global_queue:

Unlike the main queue or queues allocated with dispatch_queue_create(), the global concurrent queues schedule blocks as soon as threads become available ("non-FIFO" completion order). The global concurrent queues represent three priority bands:

       •   DISPATCH_QUEUE_PRIORITY_HIGH
       •   DISPATCH_QUEUE_PRIORITY_DEFAULT
       •   DISPATCH_QUEUE_PRIORITY_LOW

Blocks submitted to the high priority global queue will be invoked before those submitted to the default or low priority global queues. Blocks submitted to the low priority global queue will only be invoked if no blocks are pending on the default or high priority queues.

So, they are queues which run on background threads as and when they become available. They're "non-FIFO" so ordering is not guaranteed.

What, P!nk's official music video for 'So What'. Click to listen to P!nk on Spotify: http:// smarturl.it Duration: 3:46 Posted: Oct 25, 2009 WhatsApp Messenger: More than 2 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.

The 5 queues (4 background, 1 main) all have different thread priorities (-[NSThread threadPriority]) too:

                            -main- : 0.758065
      DISPATCH_QUEUE_PRIORITY_HIGH : 0.532258
   DISPATCH_QUEUE_PRIORITY_DEFAULT : 0.500000
       DISPATCH_QUEUE_PRIORITY_LOW : 0.467742
DISPATCH_QUEUE_PRIORITY_BACKGROUND : 0.000000

(tested on an iPod 4th gen and the simulator on a MacBook Pro)

P!nk - So What (Official Music Video), I will do what I can to help you. TranslationsEdit. show ▽what? (interrogative pronoun)� WhatsApp Messenger: More than 2 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.

Yes. You can run code like this on a device to test it:

dispatch_async(
    dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            NSLog(@"Block 1a");
            NSAssert(![NSThread isMainThread], @"Wrong thread!");
            NSLog(@"Block 1b");
        });
dispatch_async(
    dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            dispatch_async(dispatch_get_main_queue(), ^{
                    NSLog(@"Block 2a");
                    NSAssert([NSThread isMainThread], @"Wrong thread!");
                    NSLog(@"Block 2b");
                });
        });

what, Quickly send and receive WhatsApp messages right from your computer. Ask.com is the #1 question answering service that delivers the best answers from the web and real people - all in one place.

Global dispatch queue :

  1. Tasks in concurrent queue executes concurrently [background threads]
  2. Tasks are still started in the order that they were added to the queue

Main dispatch queue :

  1. Available serial queue that executes tasks on the application's main thread.
  2. It is usually called from a background queue when some background processing has finished and the user interface needs to be updated.

WhatsApp Web, what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more. Instead of funding a police department, a sizable chunk of a city's budget is invested in communities, especially marginalized ones where much of the policing occurs.

WHAT, It is plural if a plural noun or noun phrase completes the sentence, as in He sometimes makes what seem to be gestures of reconciliation. � Clauses with what as� Seen a font in use and want to know what it is? Upload an image to WhatTheFont to find the closest matches in our database.

What, U.S. law requires employers to create a workplace free from discrimination and harassment. But as offices go virtual, what happens when staff� More than just great coffee. Explore the menu, sign up for Starbucks® Rewards, manage your gift card and more.

What to Do When Your Employee Is Harassed Online, What's behind Trump's bizarre suggestion. Opinion by Richard Galant, CNN. Updated 9:27 AM ET, Sun August 2, 2020. CTW Andrew Yang Coronavirus Trump� This will clear your Bing search history on this device. You can't undo it.

Comments
  • Is it correct to say that global queues are concurrent queues and you cannot create your own concurrent queues (with dispatch_queue_create or something else)?
  • reference for the "non-FIFO" please?