Swift Multi-Threading using GCD For Beginners. – Hacker Noon

Types of Queues:

When dealing with GCD, there are 3 types of queues:

1- The Main Queue:

This Queue has the highest priority of all , and it runs on the main thread.
All UI updates should be done on this thread or otherwise lagging and weird crashes will occur in your application.
You use it simply like this:

2- The Global Queue:

This Queue is separated into 4 main types and a default type according to QOS(Quality of Service), from highest priority to lowest:

1- userInteractive : Work is virtually instantaneous. Similar to main thread.
2- userInitiated : Work is nearly instantaneous, such as a few seconds or less.
3- default: don’t use it usually , the type will be inferred by the system
4- utility: Work takes a few seconds to a few minutes.
5- background: Work takes significant time, such as minutes or hours.

Both, utility and background threads should be used for heavy operations that needs time in order not to black the main thread.
You can simply call one as follows:

3- Custom Queues:

Custom queues are queues that you can create on your own and give whatever QOS and attributes you want:

Using Queues Together:

Usually in a real world scenario you often need to use those queues together.
Let us say you need to do a heavy operation like downloading and image and then display this image in an imageView. 
You do it as follows:

As you can notice we do the heavy operation that can take a lot of time inside a background thread and then display the image inside an imageView using the main thread.

read original article here