SpinLock

E697521

SpinLock is a lightweight synchronization primitive in .NET used to protect shared data by repeatedly checking for lock availability instead of blocking threads.

Try in SPARQL Jump to: Statements Referenced by

Statements (49)

Predicate Object
instanceOf .NET synchronization primitive
struct
value type
alternativeTo Monitor
Mutex
SemaphoreSlim NERFINISHED
avoids kernel-mode blocking where possible
canCause CPU starvation if held too long
constructor SpinLock(bool enableThreadOwnerTracking)
defaultBehavior thread owner tracking disabled
definedInNamespace System.Threading NERFINISHED
designedFor low-level synchronization
protecting shared data
documentedIn Microsoft .NET API reference NERFINISHED
hasMethod Enter
Enter(ref bool lockTaken)
Exit
Exit(bool useMemoryBarrier)
TryEnter
TryEnter(int millisecondsTimeout, ref bool lockTaken)
TryEnter(ref bool lockTaken)
hasProperty IsHeld
IsHeldByCurrentThread
IsThreadOwnerTrackingEnabled
incorrectUseCanLeadTo deadlocks
high CPU usage
livelocks
introducedInVersion .NET Framework 4.0 NERFINISHED
languageSupport C# NERFINISHED
F# NERFINISHED
VB.NET NERFINISHED
notRecommendedFor code that may block while holding the lock
long-running critical sections
single-CPU systems
notReentrant true
optimizedFor low-contention scenarios
option thread owner tracking enabled
partOf .NET NERFINISHED
.NET Core NERFINISHED
.NET Framework NERFINISHED
recommendedFor very short critical sections
requires careful use of lockTaken flag
paired Enter and Exit calls
supports timeout in TryEnter
synchronizationStyle busy-waiting
spinning
threadSafety struct must not be copied after initialization
usedTo coordinate access to shared resources
uses memory barriers for correctness

Referenced by (1)

Full triples — surface form annotated when it differs from this entity's canonical label.

System.Threading containsType SpinLock