Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6216059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:09:57+00:00 2026-05-24T07:09:57+00:00

Reading Joseph Albahari’s threading tutorial , the following are mentioned as generators of memory

  • 0

Reading Joseph Albahari’s threading tutorial, the following are mentioned as generators of memory barriers:

  • C#’s lock statement (Monitor.Enter/Monitor.Exit)
  • All methods on the Interlocked class
  • Asynchronous callbacks that use the thread pool — these include asynchronous delegates, APM callbacks, and Task continuations
  • Setting and waiting on a signaling construct
  • Anything that relies on signaling, such as starting or waiting on a Task

In addition, Hans Passant and Brian Gideon added the following (assuming none of which already fits into one of the previous categories):

  • Starting or waking up a thread
  • Context switch
  • Thread.Sleep()

I was wondering if this list was complete (if a complete list could even be practically made)

EDIT additions suggested:

  • Volatile (reading implies an acquire fence, writing implies a release fence)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:09:58+00:00Added an answer on May 24, 2026 at 7:09 am

    Here is my take on the subject and to attempt to provide a quasi-complete list in one answer. If I run across any others I will edit my answer from time to time.

    Mechanisms that are generally agreed upon to cause implicit barriers:

    • All Monitor class methods including the C# keyword lock
    • All Interlocked class methods.
    • All Volatile class methods (.NET 4.5+).
    • Most SpinLock methods including Enter and Exit.
    • Thread.Join
    • Thread.VolatileRead and Thread.VolatileWrite
    • Thread.MemoryBarrier
    • The volatile keyword.
    • Anything that starts a thread or causes a delegate to execute on another thread including QueueUserWorkItem, Task.Factory.StartNew, Thread.Start, compiler supplied BeginInvoke methods, etc.
    • Using a signaling mechanism such as ManualResetEvent, AutoResetEvent, CountdownEvent, Semaphore, Barrier, etc.
    • Using marshaling operations such as Control.Invoke, Dispatcher.Invoke, SynchronizationContext.Post, etc.

    Mechanisms that are speculated (but not known for certain) to cause implicit barriers:

    • Thread.Sleep (proposed by myself and possibly others due to the fact that code which exhibits a memory barrier problem can be fixed with this method)
    • Thread.Yield
    • Thread.SpinWait
    • Lazy<T> depending on which LazyThreadSafetyMode is specified

    Other notable mentions:

    • Default add and remove handlers for events in C# since they use lock or Interlocked.CompareExchange.
    • x86 stores have release fence semantics
    • Microsoft’s implemenation of the CLI has release fence semantics on writes despite the fact that the ECMA specification does not mandate it.
    • MarshalByRefObject seems to suppress certain optimizations in subclasses which may make it appear as if an implicit memory barrier were present. Thanks to Hans Passant for discovering this and bringing it to my attention.1

    1This explains why BackgroundWorker works correctly without having volatile on the underlying field for the CancellationPending property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading Joseph Albahari's brilliant book on C# 4.0 and I came
While reading C# 3.0 in a Nutshell by Joseph and Ben Albahari , I
I was reading C# 4.0 in a Nutshell by Joseph and Ben Albahari and
Reading the following article, I managed to put a legend outside plot. How to
Reading the Python 3.2 tutorial here , towards the end one of the examples
Reading the book I found the following: The way of thinking when you model
Reading the Redis documentation on Virtual Memory at: http://redis.io/topics/virtual-memory With regards to vm-max-threads they
reading this https://developers.google.com/in-app-payments/docs/tutorial Quoted from the above page: Because you sign the JWT using
Reading through the following instruction table manual I see that integer multiplication is often
Reading this question I found this as (note the quotation marks) code to solve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.