Skip to content

Instantly share code, notes, and snippets.

@luca-bernardi
Created February 23, 2014 21:06
Show Gist options
  • Save luca-bernardi/9177272 to your computer and use it in GitHub Desktop.
Save luca-bernardi/9177272 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface LBRObject : NSObject
@end
@implementation LBRObject
- (void)execute
{
@synchronized(self) {
NSLog(@"1) %@", [NSThread currentThread]);
dispatch_queue_t queue = dispatch_queue_create("com.lucabernardi.serial_queue", DISPATCH_QUEUE_SERIAL);
dispatch_sync(queue, ^{
@synchronized(self) {
NSLog(@"2) %@", [NSThread currentThread]);
}
});
}
}
@end
int main(int argc, const char * argv[])
{
@autoreleasepool {
LBRObject *obj = [LBRObject new];
[obj execute];
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment