If several threads need access to a single resource, that access must be controlled. The answer to this is Semaphores. Federico Zanetello gives us several great tips on implementing Semaphores along with code samples. If don't have a solid grasp on when to use Semaphores, this post is clear, well-written, and very informative.
A Quick Look at Semaphores in Swift by Federico Zanetello