Swift Threads: The Guide

Nothing To Do With Clothes

Steven Curtis
8 min readMar 9, 2023
Photo by arjun kumar on Unsplash

I’ve previously written that threads should be handled by the view model in MVVM. I’ve written about GDC. I’ve even completed some work around RunLoop in Swift.

I haven’t made what threads are clear.

I’ll fix that now.

Difficulty: Beginner | Easy | Normal | Challenging

This article has been developed using Xcode 14.2, and Swift 5.7.2

Prerequisites

Keywords and Terminology:

RunLoop: an object that manages events and tasks within a thread, including the main thread, and ensures the thread remains active and responsive.

Thread: Tasks can have their own threads of execution to stop long-running tasks block the execution of the rest of the application

Threads

A thread can be thought of as a sequence of instructions that can be executed (independently of other threads). By executing tasks on multiple threads an application can perform multiple tasks simultaneously which can ultimately increase performance and responsiveness.

An Example

--

--