There is language-level support in C# for per-thread storage of variables. The same goes for the volatile
keyword. C++ also supports per-thread variables, but with per-thread initialization and de-initialization. It has a volatile
keyword too, but it’s meaning is quite different from C#. Read on to learn how to properly use these features in each language.
Posts Tagged volatile
Writing multi-threaded code is one of the keys to maximizing performance. Currently, this means creating your own threads and synchronizing them with C# keywords like lock
and volatile
as well as .NET classes like [ThreadStatic]
and Interlocked
. Today we’ll take a look at how these are implemented behind the scenes by IL2CPP to get some understanding of what we’re really telling the computer to do when we use them.
Today’s article is the final installment in the series before we wrap things up next week. We’ll talk about C#’s built-in support for multi-threading and cover some odds and ends that were missed in the previous articles.