Skip to content

Instantly share code, notes, and snippets.

@albertodebortoli
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save albertodebortoli/9445448 to your computer and use it in GitHub Desktop.

Select an option

Save albertodebortoli/9445448 to your computer and use it in GitHub Desktop.
Objective-C Concurrency/Threading/GCD Trivia
@synchronized(self) {
NSLog(@"%i", 1);
dispatch_queue_t queue = dispatch_queue_create("com.albertodebortoli.serial_queue", DISPATCH_QUEUE_SERIAL);
dispatch_sync(queue, ^{
NSLog(@"%i", 2);
@synchronized(self) {
NSLog(@"%i", 3);
}
NSLog(@"%i", 4);
});
NSLog(@"%i", 5);
}
// what's the order of the logs and why, does the program execute until the end?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment