Can anyone explain with really clear use cases what the purpose of dispatch_sync in GCD is for? I can\'t understand where and why I would have to u
dispatch_sync
GCD
dispatch_sync is semantically equivalent to a traditional mutex lock.
dispatch_sync(queue, ^{ //access shared resource });
works the same as
pthread_mutex_lock(&lock); //access shared resource pthread_mutex_unlock(&lock);