Skip to content

Instantly share code, notes, and snippets.

@PsychoH13
Created June 21, 2014 20:33
Show Gist options
  • Save PsychoH13/244b114c91354c7a9e53 to your computer and use it in GitHub Desktop.
Save PsychoH13/244b114c91354c7a9e53 to your computer and use it in GitHub Desktop.
import Cocoa
let concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
let serialQueue = dispatch_queue_create("queue", 0)
let array = [ "'0'", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'10'" ]
for x in 1..10 {
let str = array[x];
dispatch_async(serialQueue) { println("serial: \(x) \(str)") }
dispatch_async(concurrentQueue) { println("concurrent: \(x) \(str)") }
}
dispatch_main()
concurrent: 8 '8'
concurrent: 6 '6'
concurrent: 1 '1'
concurrent: 2 '2'
serial: 1 '1'
concurrent: 7 '7'
concurcroennctcu:or nr3ce un'rt3r:'e
n5t :' 54'
'4'
consceurriraeln:t :2 9' 2''9
'
serial: 3 '3'
serial: 4 '4'
serial: 5 '5'
serial: 6 '6'
serial: 7 '7'
serial: 8 '8'
serial: 9 '9'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment