Use dispatch_barrier_sync instead of dispatch_sync