Today, we’re going to look at the power of the old-school Thread APIs, and demonstrate how much it has in common with Tasks, the modern building block of Swift Concurrency.
Back when I was a fresh-faced junior, we had a really smart engineer on my team, Jeff. I asked him to explain iOS concurrency to my graduate cohort, and he explained there were 3 levels of abstraction:
Operation & OperationQueue at the top-level, with advanced functionality.
GCD as your bread-and-butter for basic concurrency workloads.
Thread for low-level precise management of actual threads.
My impostor-syndrome-riddled brain filled in the blanks: I knew any time I heard “low-level” it meant “for geniuses”.
The Thread API was out-of-bounds, for the really smart engineers.
Until today.
It wasn’t until I started writing this piece that I realised, a lot of the APIs available in Thread are copied by the Task in Swift Concurrency. By comparing them, we can understand both at a deeper level.
Paid subscribers get full access to this article, plus my full Quick Hacks library. You’ll also get all my long-form content 3 weeks before anyone else.
To celebrate April Fool’s Day, I’m offering a comically large 99% off discount*.
Keep reading with a 7-day free trial
Subscribe to Jacob’s Tech Tavern to keep reading this post and get 7 days of free access to the full post archives.