0 votes
in Technology by (1.7m points)

How does dispatch_once manages to run only once?

1 Answer

0 votes
by (1.7m points)
dispatch_once() is synchronous process and all GCD methods do things asynchronously (case in point, dispatch_sync() is synchronous)
The entire idea of dispatch_once() is “perform something once and only once”, which is precisely what we’re doing. dispatch_once that’s used to guarantee that something happens exactly once, no matter how violent the program’s threading becomes.