@Deprecated public class SpinLock extends Object
This spin lock 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 }
Further analysis however, shows that spin locks behave really bad under heavy contention and where the number of threads exceeds the number of cores, which are common scenarios for a server, so this class was removed from usage, preferring standard locks instead.
Modifier and Type | Class and Description |
---|---|
class |
SpinLock.Lock
Deprecated.
|
Constructor and Description |
---|
SpinLock()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isLocked()
Deprecated.
|
boolean |
isLockedThread()
Deprecated.
|
SpinLock.Lock |
lock()
Deprecated.
|
public SpinLock.Lock lock()
public boolean isLocked()
public boolean isLockedThread()
Copyright © 1995-2017 Webtide. All Rights Reserved.