public class VanillaThreadLock extends Object implements ThreadLock
| Constructor and Description |
|---|
VanillaThreadLock(LongValue twoThreadId,
long timeoutMs) |
| Modifier and Type | Method and Description |
|---|---|
void |
lock(int threadId)
Lock the resource using a threadId
|
boolean |
tryLock(int threadId)
Try to lock once or fail
|
void |
unlock(int threadId)
Unlock for a threadId
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgettid, lock, tryLock, unlockpublic VanillaThreadLock(LongValue twoThreadId, long timeoutMs)
public boolean tryLock(int threadId)
throws IllegalStateException
ThreadLocktryLock in interface ThreadLockthreadId - to attempt to lock forIllegalStateException - if the same threadId already holds the lockpublic void lock(int threadId)
throws InterruptedRuntimeException
ThreadLocklock in interface ThreadLockthreadId - to lockInterruptedRuntimeException - if an interrupt occurred before or during a busy loop retry. It won't throw this if the lock can be obtained immediately.public void unlock(int threadId)
throws IllegalStateException
ThreadLockunlock in interface ThreadLockthreadId - to unlockIllegalStateException - if the thread previously held the lock but doesn't hold it now.Copyright © 2022. All rights reserved.