multithreading
ThreadPool max threads
Firstly, your “knowledge” of the defaults is incorrect. The limit of 25 threads per processor was back from .NET 1.1. It was increased in .NET 2, and now: Beginning with the .NET Framework version 4, the default size of the thread pool for a process depends on several factors, such as the size of the … Read more
How do you lazily construct a singleton object thread-safely? [duplicate]
Here’s Meyer’s singleton, a very simple lazily constructed singleton getter: Singleton &Singleton::self() { static Singleton instance; return instance; } This is lazy, and C++11 requires it to be thread-safe. In fact, I believe that at least g++ implements this in a thread-safe manner. So if that’s your target compiler or if you use a compiler … Read more
Wait until all threads are finished in Python
Put the threads in a list, .start() each thread, and then .join() each thread: threads = [ Thread(…), Thread(…), Thread(…), ] # Start all threads. for t in threads: t.start() # Wait for all threads to finish. for t in threads: t.join()
Getting list of currently active managed threads in .NET?
If you’re willing to replace your application’s Thread creations with another wrapper class, said wrapper class can track the active and inactive Threads for you. Here’s a minimal workable shell of such a wrapper: namespace ThreadTracker { using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading; public class TrackedThread { private static readonly IList<Thread> threadList = new List<Thread>(); … Read more
Building asynchronous `future` callback chain from compile-time dependency graph (DAG)
The easiest way is to start from the entry node of the graph, as if you were writing the code by hand. In order to solve the join problem, you can not use a recursive solution, you need to have a topological ordering of your graph, and then build the graph according to the ordering. … Read more
How to properly Multithread in OpenCV in 2019?
First of all, thank you for the clarity of the question. Q: Is it okay to use (multi)threading on application level with OpenCV? A: Yes it is totally ok to use multithreading on application level with OpenCV unless and until you are using functions which can take advantage of multithreading such as blurring, colour space … Read more
Lock free stack and queue in C#
Late, but better than never I thought I would add Julian Bucknalls articles to this list. But he does not have performance numbers. In my testing of his structures the list scaled well compared to locking (very low kernel usage compared to ReaderWriterLock). His blog has a series of articles on lock free structures in … Read more
What is “Locked ownable synchronizers” in thread dump?
TL;DR: write locks appear in the “ownable synchronizers” list, read locks don’t. I ended up with the following MVCE to try and understand what’s with “ownable synchronizer”. The idea was to have two threads locking/unlocking read/write reentrant locks and see the effect on different thread dumps at different timings (taken in jVisualVM while the Eclipse … Read more