Created
November 28, 2017 03:07
-
-
Save mahmudahsan/d9c080fc8eadd664849079f0b95b8483 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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