.Net 4 introduced the Lazy<T> type which allows you to create an object that can be lazily initialized so that you can delay the creation of large objects, for instance.
After watching Gael’s recent SkillsMatter talk on multithreading I’ve put together some notes from a very educational talk:
Hardware Cache Hierarchy
I’ve covered the topic of using SmartThreadPool and the framework thread pool in more details here and here, this post will instead focus on a more specific scenario where the rate of new work items being…
Occasionally you might want to make the value of a static or instance field local to a thread (i.e. each thread holds an independent copy of the field), what you need in this case, is a thread-local storage.
For a while now I’ve been curious as to whether the CLR uses the ThreadPool to execute a delegate when BeginInvoke is called:
[code lang=”csharp”]private void InvokeFunc(Func<int> func){ func.BeginInvoke(null…
Here is a queue class based on the implementation Marc Gravell provided in this StackOverflow question:
[code lang=”csharp”]/// <summary>/// A thread-safe fixed sized queue implementation/// See…
As I’ve mentioned in my previous post, the biggest problem with using the .Net ThreadPool is that there’s a limited number of threads in the pool and you’ll be sharing with other .Net framework classes so you need to be on your best behaviour and not hog the…
There are a lot of discussions on the pros and cons of using the ThreadPool and creating your own threads. Having spent a bit of time reading what others have to say, here’s a summary of the things I’ve picked up on.
Having run into a bit of deadlocking issue while working on Bingo.Net I spent a bit of time reading into the Producer-Consumer pattern and here’s what I learnt which I hope you’ll find useful too.
Ever wondered when you should use Monitor.Pulse and when you should use Monitor.PulseAll given that only one thread will be able to acquire the lock even if you wake up multiple threads? I did, and that’s when I stumbled across a…