gcc: Synchronization

1 
1 8.8 Synchronization
1 ===================
1 
1 GNU Objective-C provides support for synchronized blocks:
1 
1        @synchronized (ObjCClass *guard) {
1          ...
1        }
1 
1  Upon entering the '@synchronized' block, a thread of execution shall
1 first check whether a lock has been placed on the corresponding 'guard'
1 object by another thread.  If it has, the current thread shall wait
1 until the other thread relinquishes its lock.  Once 'guard' becomes
1 available, the current thread will place its own lock on it, execute the
1 code contained in the '@synchronized' block, and finally relinquish the
1 lock (thereby making 'guard' available to other threads).
1 
1  Unlike Java, Objective-C does not allow for entire methods to be marked
1 '@synchronized'.  Note that throwing exceptions out of '@synchronized'
1 blocks is allowed, and will cause the guarding object to be unlocked
1 properly.
1 
1  Because of the interactions between synchronization and exception
1 handling, you can only use '@synchronized' when compiling with
1 exceptions enabled, that is with the command line option
1 '-fobjc-exceptions'.
1