Thread.VolatileRead 方法

定义

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

重载

VolatileRead(SByte)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(Single)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(UIntPtr)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(UInt32)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(UInt64)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(Object)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(UInt16)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(Int64)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(IntPtr)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(Int16)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(Double)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(Byte)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(Int32)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

VolatileRead(SByte)

重要

此 API 不符合 CLS。

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static System::SByte VolatileRead(System::SByte % address);
[System.CLSCompliant(false)]
public static sbyte VolatileRead (ref sbyte address);
public static sbyte VolatileRead (ref sbyte address);
[<System.CLSCompliant(false)>]
static member VolatileRead : sbyte -> sbyte
static member VolatileRead : sbyte -> sbyte
Public Shared Function VolatileRead (ByRef address As SByte) As SByte

参数

address
SByte

要读取的字段。The field to be read.

返回

SByte

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

属性

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(Single)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static float VolatileRead(float % address);
public static float VolatileRead (ref float address);
static member VolatileRead : single -> single
Public Shared Function VolatileRead (ByRef address As Single) As Single

参数

address
Single

要读取的字段。The field to be read.

返回

Single

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(UIntPtr)

重要

此 API 不符合 CLS。

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static UIntPtr VolatileRead(UIntPtr % address);
[System.CLSCompliant(false)]
public static UIntPtr VolatileRead (ref UIntPtr address);
public static UIntPtr VolatileRead (ref UIntPtr address);
[<System.CLSCompliant(false)>]
static member VolatileRead : unativeint -> unativeint
static member VolatileRead : unativeint -> unativeint
Public Shared Function VolatileRead (ByRef address As UIntPtr) As UIntPtr

参数

address
UIntPtr

要读取的字段。The field to be read.

返回

UIntPtr

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

属性

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(UInt32)

重要

此 API 不符合 CLS。

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static System::UInt32 VolatileRead(System::UInt32 % address);
[System.CLSCompliant(false)]
public static uint VolatileRead (ref uint address);
public static uint VolatileRead (ref uint address);
[<System.CLSCompliant(false)>]
static member VolatileRead : uint32 -> uint32
static member VolatileRead : uint32 -> uint32
Public Shared Function VolatileRead (ByRef address As UInteger) As UInteger

参数

address
UInt32

要读取的字段。The field to be read.

返回

UInt32

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

属性

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(UInt64)

重要

此 API 不符合 CLS。

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static System::UInt64 VolatileRead(System::UInt64 % address);
[System.CLSCompliant(false)]
public static ulong VolatileRead (ref ulong address);
public static ulong VolatileRead (ref ulong address);
[<System.CLSCompliant(false)>]
static member VolatileRead : uint64 -> uint64
static member VolatileRead : uint64 -> uint64
Public Shared Function VolatileRead (ByRef address As ULong) As ULong

参数

address
UInt64

要读取的字段。The field to be read.

返回

UInt64

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

属性

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(Object)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static System::Object ^ VolatileRead(System::Object ^ % address);
public static object? VolatileRead (ref object? address);
public static object VolatileRead (ref object address);
static member VolatileRead : obj -> obj
Public Shared Function VolatileRead (ByRef address As Object) As Object

参数

address
Object

要读取的字段。The field to be read.

返回

Object

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(UInt16)

重要

此 API 不符合 CLS。

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static System::UInt16 VolatileRead(System::UInt16 % address);
[System.CLSCompliant(false)]
public static ushort VolatileRead (ref ushort address);
public static ushort VolatileRead (ref ushort address);
[<System.CLSCompliant(false)>]
static member VolatileRead : uint16 -> uint16
static member VolatileRead : uint16 -> uint16
Public Shared Function VolatileRead (ByRef address As UShort) As UShort

参数

address
UInt16

要读取的字段。The field to be read.

返回

UInt16

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

属性

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(Int64)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static long VolatileRead(long % address);
public static long VolatileRead (ref long address);
static member VolatileRead : int64 -> int64
Public Shared Function VolatileRead (ByRef address As Long) As Long

参数

address
Int64

要读取的字段。The field to be read.

返回

Int64

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(IntPtr)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static IntPtr VolatileRead(IntPtr % address);
public static IntPtr VolatileRead (ref IntPtr address);
static member VolatileRead : nativeint -> nativeint
Public Shared Function VolatileRead (ByRef address As IntPtr) As IntPtr

参数

address
IntPtr

要读取的字段。The field to be read.

返回

IntPtr

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(Int16)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static short VolatileRead(short % address);
public static short VolatileRead (ref short address);
static member VolatileRead : int16 -> int16
Public Shared Function VolatileRead (ByRef address As Short) As Short

参数

address
Int16

要读取的字段。The field to be read.

返回

Int16

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(Double)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static double VolatileRead(double % address);
public static double VolatileRead (ref double address);
static member VolatileRead : double -> double
Public Shared Function VolatileRead (ByRef address As Double) As Double

参数

address
Double

要读取的字段。The field to be read.

返回

Double

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(Byte)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static System::Byte VolatileRead(System::Byte % address);
public static byte VolatileRead (ref byte address);
static member VolatileRead : byte -> byte
Public Shared Function VolatileRead (ByRef address As Byte) As Byte

参数

address
Byte

要读取的字段。The field to be read.

返回

Byte

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于

VolatileRead(Int32)

读取字段值。Reads the value of a field. 无论处理器的数目或处理器缓存的状态如何,该值都是由计算机的任何处理器写入的最新值。The value is the latest written by any processor in a computer, regardless of the number of processors or the state of processor cache.

public:
 static int VolatileRead(int % address);
public static int VolatileRead (ref int address);
static member VolatileRead : int -> int
Public Shared Function VolatileRead (ByRef address As Integer) As Integer

参数

address
Int32

要读取的字段。The field to be read.

返回

Int32

由任何处理器写入字段的最新值。The latest value written to the field by any processor.

注解

VolatileReadVolatileWrite 适用于同步的特殊情况。VolatileRead and VolatileWrite are for special cases of synchronization. 正常情况下,c # lock 语句、Visual Basic SyncLock 语句和 Monitor 类提供更简单的替代方法。Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.

在多处理器系统上, VolatileRead 获取由任何处理器写入内存位置的最新值。On a multiprocessor system, VolatileRead obtains the very latest value written to a memory location by any processor. 这可能需要刷新处理器缓存。This might require flushing processor caches.

即使在单处理器系统上, VolatileRead 也要 VolatileWrite 确保某个值已读取或写入内存,而不缓存 (例如,在处理器寄存器) 中。Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). 因此,您可以使用它们来同步对可以由其他线程或硬件更新的字段的访问。Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.

调用此方法只会影响单个内存访问。Calling this method affects only a single memory access. 若要为字段提供有效同步,对字段的所有访问必须使用 VolatileReadVolatileWriteTo provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.

备注

在 c # 中,对 volatile 字段使用修饰符可保证对该字段的所有访问都使用 VolatileReadVolatileWriteIn C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite.

适用于