February 2018
Intermediate to advanced
298 pages
8h 22m
English
A race condition is a problem that can happen if a DOM is allowed to be accessed by web workers. A race condition is a condition where two threads race, or compete, to read/modify a single data source. This is dangerous because when both threads try to modify the data at same time, and it is unknown which one will modify the data first. Consider the following example.
Suppose two threads are working on the same variable in memory:
// thread 1 - pseudo program codeif variable == 5: asyncOperationWhichTakes200MS() // just here thread 2 modifies variable to 10 res = variable * 5 // res is now 50 instead of 25 // unpredicatable behavior ahead
Race conditions can be avoided by using semaphores, which is nothing ...
Read now
Unlock full access