Quantcast
Channel: scikit-learn - 盆暗の学習記録
Viewing all articles
Browse latest Browse all 69

Answer by Nathan Day for Which is threadsafe atomic or non atomic?

$
0
0

atomic makes doing the following thread safe.

self.myProperty = value;

or

id value = self.myProperty

it does not make the following thread safe

[myPorperty addObject:value];

Atomic makes it thread safe to set or get a property, but it doesn't make calling any methods of that property itself thread safe.

setting or getting values can take more than one CPU instruction and so that means the setting or getting can be interrupted half way though and another thread can do something making the progress of the previous thread in setting or getting the value invalid.

atomic says set or get the value in a way so that it happens as if it happened in one indivisible instruction and so no other thread can step in half way and screw things up.

Immutable object are thread safe simple because you cannot change them, of cause you can change a property from one immutable object another so that part will not be thead safe unless you make it atomic.


Viewing all articles
Browse latest Browse all 69

Trending Articles