# Understanding Lazy thread safety modes

DevFeed: [Understanding Lazy thread safety modes](<https://devfeed.tech/articles/understanding-lazy-thread-safety-modes-116292.md>)

Original publisher: [Read original article](<https://andrewlock.net/understanding-lazy-thread-safety-modes/>)

Author: Andrew Lock

Published: 2026-11-03T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [thread safe data sharing](<https://devfeed.tech/topics/thread-safe-data-sharing.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [locking](<https://devfeed.tech/topics/locking.md>)

Tags: [caching](<https://devfeed.tech/tags/caching.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [lazy](<https://devfeed.tech/tags/lazy.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [thread](<https://devfeed.tech/tags/thread.md>), [thread-safety](<https://devfeed.tech/tags/thread-safety.md>)

## AI overview

`Lazy<T>` defers factory execution until `Value` is accessed. `None` is for single-threaded use and caches factory exceptions; concurrent access is unsafe. `PublicationOnly` lets concurrent callers run the factory independently, publishes the first successful result for everyone, and does not cache exceptions--each factory call that throws still reports its own exception. `ExecutionAndPublication` runs the factory once while other callers wait, and caches any exception, so later accesses keep throwing it. The article says `ExecutionAndPublication` avoids duplicate work and allocations, while `PublicationOnly` may be faster when initialization is cheap, safe to repeat, and lock contention is significant. `LazyInitializer.EnsureInitialized` offers similar publication behaviors without a `Lazy<T>` allocation and does not cache exceptions. A proposed `cacheExceptions` option was approved but was not yet implemented in the described account.

## Source excerpt

In this post I look at how the different `LazyThreadSafetyMode` values work with `Lazy`, and how exceptions are handled for each mode