I'm working on a chrome extension, which use asynchronous functions, and I have a global string variable which is set by a function, like that:
my_global_variable += a_string
I would know if there is a risk that, if I read my_global_variable in another function at the same time, I got just a portion of a_string.
In other words, does the concatenation ( more generally an instruction) is an atomic operation?
Javascript in the browser is singled threaded (unless using HTML5 Web Workers) so there is no contention around variable access. There was threading in Chrome via the Gears plugin but that has been discontinued in favour of HTML5 functionality e.g. Web Workers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With