same variable, they have potentials for race conditions • The expected value of I is 2,000,000 but the actual value is 1,330,864 this is because of race condition
atomically. • Any time a variable is changed that is shared by many threads, it needs to be done atomically. • Ruby gives one tool to do so : the lock aka the mutex. • Mutex = Mutual exclusion = only one thread can be executing this code at a time
lock • There is always one GIL for each interpreter process • Only allows one thread to run at a time • Limits the amount of parallelism reachable through concurrency of a single interpreter process with multiple threads • Ruby GIL only applies to non I/O operations