| IMapTKey, TValueTryLock Method (TKey, Int64, TimeUnit) |
Tries to acquire the lock for the specified key.
Namespace:
Hazelcast.Core
Assembly:
Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.12.2
Syntax bool TryLock(
TKey key,
long time,
TimeUnit timeunit
)
Function TryLock (
key As TKey,
time As Long,
timeunit As TimeUnit
) As Boolean
bool TryLock(
TKey key,
long long time,
TimeUnit timeunit
)
abstract TryLock :
key : 'TKey *
time : int64 *
timeunit : TimeUnit -> bool
Parameters
- key
- Type: TKey
key to lock in this map - time
- Type: SystemInt64
maximum time to wait for the lock - timeunit
- Type: Hazelcast.CoreTimeUnit
TimeUnit for the ttl
Return Value
Type:
Booleantrue if lock is acquired,
false otherwise.
Remarks
Tries to acquire the lock for the specified key.
If the lock is not available then
the current thread becomes disabled for thread scheduling
purposes and lies dormant until one of two things happens:
- The lock is acquired by the current thread; or
- The specified waiting time elapses
Warning:
This method uses
GetHashCode and
Equals of binary form of
the
key, not the actual implementations of
GetHashCode and
Equals
defined in
key's class.
See Also