-
-
Save tewha/3065339 to your computer and use it in GitHub Desktop.
@synchronized doesn't retain monitored object under MRC
This file contains 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
__block id foo = [MyObject new]; | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
NSLog(@"block entering synchronized"); | |
@synchronized(foo) { | |
NSLog(@"running in synchronized"); | |
sleep(10); | |
// what does @synchronized do the now-zombie foo as part of its closure? | |
} | |
NSLog(@"block exited synchronized"); | |
}); | |
sleep(1); | |
NSLog(@"running at top level, releasing foo"); | |
[foo release]; | |
NSLog(@"running at top level, released foo"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment