Well, it depends on your implementation and many things. In MRI, there is such a thing as GVL (Giant VM Lock) that controls which thread actually executes the code at a time. You see that in MRI only one thread can execute Ruby code at a time. Therefore, while the C libraries below may allow another thread to work while they use the CPU in the C code to multiply giant numbers, the code itself cannot be executed at the same time. This means that an operator, such as an assignment, may not be launched simultaneously with another one of the assignments (although additions may be performed in parallel). Another thing that can happen is this: I think I heard that int assignments are atomic on Linux, so if you are working on Linux, it could be something too.
Linuxios
source share