Re:V8 adds support for top-level await
by jdm2212 on Tuesday September 24, 2019 @06:44PM
(#21065438)
JS is single-threaded right so (...I think...) deadlocks are actually impossible. Although I guess you can still get stuck if two pieces of code are waiting on each other to satisfy some condition (and trading control of the sole thread) without using explicit locking.
[ Parent
| on HN ]
Re:V8 adds support for top-level await
by matharmin on Wednesday September 25, 2019 @03:08AM
(#21068455)
Deadlocks can happen in any kind of concurrent system with locks. As soon as you start building & using locks with Promises, this is quite easy to happen.
That said, the need for locks in JavaScript is much less than in a typical multi-threaded language, so it's a lot easier to keep track of and avoid deadlocks, if you're even using locks at all.
Yeah, nothing about JavaScript being single threaded implies any resistance to deadlock.
Re:V8 adds support for top-level await
by jdm2212 on Tuesday September 24, 2019 @07:34PM
(#21065878)
It's still much harder to deadlock single-threaded code than multi-threaded code because single-threading eliminates the need for most locking, which in turn eliminates most opportunities to cause deadlocks.
I love setTimeout