Assume these are instance methods and -run is called.
Is the lock on self released by the time -run returns?
...
- (void)dangerous {
@synchronized (self) {
[NSException raise:@"foo" format:@"bar"];
}
}
- (void)run {
@try { [self dangerous]; }
@catch (NSException *ignored) {}
}
...
A
@synchronized(obj) { code }block is effectively equivalent tothough any particular aspect of this is really just implementation details. But yes, a
@synchronizedblock is guaranteed to release the lock no matter how control exits the block.