Skip to content

Instantly share code, notes, and snippets.

@mahmudahsan
Created November 28, 2017 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmudahsan/d9c080fc8eadd664849079f0b95b8483 to your computer and use it in GitHub Desktop.
Save mahmudahsan/d9c080fc8eadd664849079f0b95b8483 to your computer and use it in GitHub Desktop.
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let pairOfNumbers = [(2, 3), (5, 10), (4, 5)]
let operationQueue = OperationQueue()
//if set 1, it will be serial if commented it will be concurrent
operationQueue.maxConcurrentOperationCount = 1
for pair in pairOfNumbers{
operationQueue.addOperation {
let result = pair.0 * pair.1
print("Result: \(result)")
sleep(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment