Larme

Untitled

May 18th, 2021
524
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func queuing() {
  2.     var concurrentQueue = DispatchQueue(label: "test",attributes: .concurrent)
  3.     var myGroup = DispatchGroup()
  4.     var mySecondGroup = DispatchGroup()
  5.  
  6.     myGroup.enter()
  7.     mySecondGroup.enter()
  8.  
  9.     concurrentQueue.async {
  10.         for i in 0...5 {
  11.             print(i)
  12.             if (i==5) {
  13.                 myGroup.leave()
  14.             }
  15.         }
  16.     }
  17.  
  18.     myGroup.notify(queue: DispatchQueue.main) {
  19.         print("Initial Json request with List of URLs completed")
  20.         concurrentQueue.async {
  21.             for i in 10...15 {
  22.                 print(i)
  23.                 if (i==15){
  24.                     mySecondGroup.leave()
  25.                 }
  26.             }
  27.         }
  28.     }
  29.  
  30.     mySecondGroup.notify(queue: DispatchQueue.main) {
  31.         print("All Images download complete")
  32.     }
  33. }
  34.  
  35. queuing()
RAW Paste Data