public class SpinLock extends Object
This is a lock designed to protect VERY short sections of critical code. Threads attempting to take the lock will spin forever until the lock is available, thus it is important that the code protected by this lock is extremely simple and non blocking. The reason for this lock is that it prevents a thread from giving up a CPU core when contending for the lock.
try(SpinLock.Lock lock = spinlock.lock()) { // something very quick and non blocking }
Modifier and Type | Class and Description |
---|---|
class |
SpinLock.Lock |
Constructor and Description |
---|
SpinLock() |
public SpinLock.Lock lock()
public boolean isLocked()
public boolean isLockedThread()
Copyright © 1995-2015 Webtide. All Rights Reserved.