public class LockResource extends Object implements Closeable
try (LockResource r = new LockResource(lock)) { ... }
Constructor and Description |
---|
LockResource(Lock lock)
Creates a new instance of
LockResource using the given lock. |
LockResource(Lock lock,
boolean acquireLock)
Creates a new instance of
LockResource using the given lock. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases the lock.
|
boolean |
hasSameLock(LockResource other)
Returns true if the other lockresource contains the same lock.
|
public LockResource(Lock lock)
LockResource
using the given lock.lock
- the lock to acquirepublic LockResource(Lock lock, boolean acquireLock)
LockResource
using the given lock.lock
- the lock to acquireacquireLock
- whether to lock the lockpublic boolean hasSameLock(LockResource other)
other
- other LockResourcepublic void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2023. All Rights Reserved.