title: Mutex alternatives in swift
body: <p>I have a shared-memory between multiple threads. I want to prevent these threads access this piece of memory at a same time. (like <em>producer-consumer</em> problem)</p>
  
  <p><strong>Problem</strong>:</p>
  
  <p>A thread add elements to a queue and another thread reads these elements and delete them. They shouldn't access the queue simultaneously.</p>
  
  <p>One solution to this problem is to use Mutex.</p>
  
  <p>As I found, there is no Mutex in Swift. Is there any alternatives in Swift?</p>