title: dispatch group and Threading swift (Async Await)
body: <p>So I was practicing threading and I have a requirement.
  I want to wait for the first api call to finish then I want to execute the second one, (Just like await async) if the first one didn't finish I want to stop the code there until it finishes.</p>
  <p>So, I wrote this. Tell me if it is correct or if there is any better way to do this</p>
  <pre><code>func myFunction() {
      var a: Int?
      let group = DispatchGroup()
      group.enter()
      DispatchQueue.global().asyncAfter(deadline: .now() + 4) {
          a = 1
          print(&quot;First&quot;)
          group.leave()
      }
      group.wait()
      group.enter()
      DispatchQueue.global().asyncAfter(deadline: .now() + 2) {
          a = 3
          print(&quot;Second&quot;)
          group.leave()
      }
      // wait ...
      group.wait()
      group.notify(queue: .main) {
          print(a) // y
      }
  }
  </code></pre>