dotnet / dotnet/dotnet-api-docs

"The Read method is unnecessary on 64-bit systems, because 64-bit read operations are already atomic. "

Open
#1,745 0 comments 0 reactions 0 assignees View on GitHub
area-System.Threading dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

Does it matter if the process is 32 bit on a 64 bit system?

Does this mean that I can just use the variable without an `Interlocked.Read()` call if everything is 64 bit?

Like this...
``` csharp

public class Test
{

private int _value;

public void Add()
{
Interlocked.Increment(ref _value);
// can do this safely?
Console.WriteLine($"The new value is {_value}");

// or is this required?
Console.WriteLine($"The new value is (Interlocked.Read(_value)");
}
}
```

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 57970c3f-b84d-e0c2-9260-4a60d3ccd60e
* Version Independent ID: ada70915-3c7d-3c1a-1668-70027bf9bb04
* Content: [Interlocked.Read(Int64) Method (System.Threading)](https://docs.microsoft.com/en-us/dotnet/api/system.threading.interlocked.read?view=netframework-4.7.2)
* Content Source: [xml/System.Threading/Interlocked.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Threading/Interlocked.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.