开发者

Should iPhone app need be thread safe?

开发者 https://www.devze.com 2023-02-13 00:36 出处:网络
I don\'t use thread explicitly开发者_如何学JAVA, so when designing an iPhone app, e.g. using Singleton, should I need to take care of the thread issue?Beware of a singleton being called by or using an

I don't use thread explicitly开发者_如何学JAVA, so when designing an iPhone app, e.g. using Singleton, should I need to take care of the thread issue?


Beware of a singleton being called by or using any OS classes that could become multi-threaded on future multi-core hardware. Also beware of forgetting that this class isn't thread safe N years from now, reusing it, and wasting your life hunting the bug.

If not, no.


In the most part you should be safe, but I would be aware that even if you don't use threads explicitly, there are many libraries in the Apple SDK that have asynchronous callbacks (such as HTTP requests) where you will need to synchronize access across shared memory.

I hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消