|
|
|
|
|
by danabramov
5031 days ago
|
|
If I understand correctly, this corresponds to `lock` in C#: lock (_gate) {
x[i] --;
}
At least in C# it is considered preferable to lock on a private field, as opposed to locking on `this`, so nobody else also locks on your instance, potentially causing a deadlock.I suppose this applies to `@synchronized` in Objective C as well. I like that .NET Framework also provides some useful atomic methods, including this one: Interlocked.Decrement (ref x[i]);
They come in handy. |
|