software threads vs hardware threads

Software threads are threads of execution managed by the operating system. Hardware threads are a feature of some processors that allow better utilisation of the processor under some circumstances. They may be exposed to/by the operating system as appearing to be additional cores (“hyperthreading”). In Java, the threads you create maintain the software thread abstraction, … Read more

Difference between user-level and kernel-supported threads?

Edit: The question was a little confusing, so I’m answering it two different ways. OS-level threads vs Green Threads For clarity, I usually say “OS-level threads” or “native threads” instead of “Kernel-level threads” (which I confused with “kernel threads” in my original answer below.) OS-level threads are created and managed by the OS. Most languages … Read more

Difference between volatile and synchronized in Java

It’s important to understand that there are two aspects to thread safety. execution control, and memory visibility The first has to do with controlling when code executes (including the order in which instructions are executed) and whether it can execute concurrently, and the second to do with when the effects in memory of what has been done … Read more

What does threadsafe mean?

Eric Lippert has a nice blog post entitled What is this thing you call “thread safe”? about the definition of thread safety as found of Wikipedia. 3 important things extracted from the links : “A piece of code is thread-safe if it functions correctly during simultaneous execution by multiple threads.” “In particular, it must satisfy the need for … Read more

Proper use of mutexes in Python

I don’t know why you’re using the Window’s Mutex instead of Python’s. Using the Python methods, this is pretty simple: But note, because of the architecture of CPython (namely the Global Interpreter Lock) you’ll effectively only have one thread running at a time anyway–this is fine if a number of them are I/O bound, although … Read more