r/programming • • Dec 19 '15

4 JavaScript Design Patterns You Should Know

https://scotch.io/bar-talk/4-javascript-design-patterns-you-should-know
0 Upvotes

4 comments sorted by

View all comments

4

u/inmatarian Dec 20 '15

Javascript

and

Race conditions occur in multi-threaded applications when more than one thread tries to access the same resource. Singletons are susceptible to race conditions, such that if no instance were initialized first, two threads could then create two objects instead of returning and instance. This defeats the purpose of a singleton. Therefore, developers must be privy to synchronization when implementing singletons in multithreaded applications.

excuse me?

1

u/Patman128 Dec 20 '15

Yeah, that is... what? Multithreaded? In JavaScript?

We have Web Workers but they run completely isolated, so there's no issues.