Objective C, What is the best way to convert volatile in Java into Objective C?

后端 未结 3 977
北恋
北恋 2020-12-28 10:40

I am trying to convert Java code into Objective C code. And the java code contains variables defined as volatile. I looked online and \"volatile\" usage in java as follwing<

3条回答
  •  一生所求
    2020-12-28 11:22

    Sharing mutable objects between different threads can be a big headache and cause bugs that are difficult to track down. Objective-c has a big preference towards immutable objects. I'd suggest that if possible, you find a way to pass around immutable objects instead if that is possible. Then you don't have to worry about a shared object being written to at all.

提交回复
热议问题