12c (12.2.1.4.0)
E90869-02
Namespace: Tangosol.Util.Collections
Assembly: Coherence (in Coherence.dll) Version: 12.2.1.4014 (12.2.1.4014)
Syntax
C# |
---|
public bool AcquireReadLock( int timeout ) |
Parameters
- timeout
- Type: System..::..Int32
Timeout in milliseconds.
Return Value
true if a lock was acquired within the specified time, false otherwise.
Remarks
Multiple threads can hold read locks at the same time, but no thread will be able to acquire a write lock until all read locks are released.
This method should always be used in combination with a
ReleaseReadLock()()()() method in the following manner:
CopyC#
if (dict.AcquireReadLock(timeout))
{
try
{
// access dictionary
}
finally
{
dict.ReleaseReadLock();
}
}
It is entirely up to you how to handle the case when the AcquireReadLock method returns false. For example, you can ignore the fact, throw an exception, or retry the operation by placing the code above within a loop.