Concurrency in Swift

Concurrency means “running multiple tasks simultaneously”. Concurrency allows iOS devices to handle background tasks (such as downloading or processing data) while maintaining a responsive user interface. In iOS, you can manage concurrent tasks using Grand Central Dispatch (or GCD), and Operations (formally known as NSOperation). In order to achieve concurrency, iOS provides three ways as follows:
 

Dispatch queues:

An object that manages the execution of tasks serially or concurrently on your app’s main thread or on a background thread.
Dispatch queues are FIFO queues to which your application can submit tasks in the form of block objects. Dispatch queues execute tasks either serially or concurrently. Work submitted to dispatch queues executes on a pool of threads managed by the system. Except for the dispatch queue representing your app’s main thread, the system makes no guarantees about which thread it uses to execute a task.
 

Threads:

Use this class when you want to have an Objective-C method run in its own thread of execution. Threads are especially useful when you need to perform a lengthy task, but don’t want it to block the execution of the rest of the application. In particular, you can use threads to avoid blocking the main thread of the application, which handles user interface and event-related actions. Threads can also be used to divide a large job into several smaller jobs, which can lead to performance increases on multi-core computers.
The Thread class supports semantics similar to those of Operation for monitoring the runtime condition of a thread. You can use these semantics to cancel the execution of a thread or determine if the thread is still executing or has finished its task.
 

Operation:

An abstract class that represents the code and data associated with a single task.
Because the Operation class is an abstract class, you do not use it directly but instead subclass or use one of the system-defined subclasses to perform the actual task. Despite being abstract, the base implementation of Operation does include significant logic to coordinate the safe execution of your task.