max_ max_ - 1 year ago 90
iOS Question

What does @synchronized() do?

I just created a singleton method, and I would like to know what the function

does, as I use it frequently, but do not know the meaning.

Answer Source

It declares a critical section around the code block. In multithreaded code, @synchronized guarantees that only one thread can be executing that code in the block at any given time.

If you aren't aware of what it does, then your application probably isn't multithreaded, and you probably don't need to use it (especially if the singleton itself isn't thread-safe).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download