Книга: C# 2008 Programmer
Using Interlocked Class
Using Interlocked Class
Because incrementing and decrementing are such common operations in programming, the .NET Framework class library provides the Interlocked
class for performing atomic operations for variables that are shared by multiple threads. You can rewrite the preceding example using the Increment() method from the static Interlocked class:
static void IncrementVar() {
Interlocked.Increment(ref _value);
}
You need to pass in the variable to be incremented by reference to the Increment()
method. When a thread encounters the Increment()
statement, all other threads executing the same statement must wait until the incrementing is done.
The Interlocked
class also includes the Decrement()
class that, as its name implies, decrements the specified variable by one.
- SERVER PRIORITY CLASS
- Using C# Lock
- Класс Interlocked
- InterBase Classic Server под Linux
- Каталог BIN в InterBase Classic Server для Linux
- Classic
- Classic vs SuperServer
- Рекомендации по выбору архитектуры: Classic или SuperServer?
- Эффективное взаимодействие процессов архитектуры Classic Server
- Yaffil Classic Server - замена InterBase Classic 4.0
- Caveats using NAT
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces