Friday, 23 August 2013

the @synchronized in Objective-C

the @synchronized in Objective-C

@synchronized(self.runningOperations) { line 1
[self.runningOperations addObject:operation]; line 2
}
when I debug these code .at first it runs the line 1 ,then go to the line
2.it's all right,but after this ,it go to the line 1 again,then go to the
line 2,then jump out the @synchronized. but when I print the
runningOperations,the first time it runs the line 2 code,the Object not
add into self.runningOperations,it is added at the second time. why it run
twice,and why the Object add into self.runningOperations in the second
time?

No comments:

Post a Comment