Better Programming

Advice for programmers.

Follow publication

Member-only story

Guide to Multi-Threading — GCD in iOS

Write concurrent code

Neel Bakshi
Better Programming
Published in
10 min readApr 26, 2021

--

Colorful threads
Photo by John Anvik on Unsplash.

Nowadays, mobile devices come with a lot of powerful CPUs at their disposal. This gives you the ability to make apps that are highly performant. Imagine your app is an image gallery app where you have to build a slick UI with which the user can interact while simultaneously uploading and downloading their 25MB HD images.

You would never want your app to stop responding to the user’s touches while the images are being uploaded or downloaded (and vice versa). Therefore, in order to make sure that you do not end up in this scenario, you need to make sure that both of them can happen without affecting each other. This is where the concept of multi-threading comes in.

Multi-threading is a broad concept that enables developers to inject either concurrency or parallelism into our software so that the tasks our software needs to perform are performed by optimally using the CPU’s time.

  • Parallelism: The process in which multiple tasks run together in parallel.
  • Concurrency: This is a process that gives the illusion of multiple tasks being run in parallel. The tasks are divided up in such a way that they are time-sliced to take up the CPU’s time in an optimized way, but they are not actually running in parallel.

--

--

Neel Bakshi
Neel Bakshi

Written by Neel Bakshi

Guy who handles everything mobile @headout among other things! Ex @practo

Responses (1)

Write a response