Closed qwenger closed 2 years ago
Note 2:
async
but without using an await
works (though it is not very useful...):var b = {};
async function a() {
b.x = 1;
}
a();
while (!b.x) {} // does not hang
qjs
and node
.~ Busy-waiting hangs in all tested consoles, which is actually kind of expected because js is single-threaded.
I have trouble getting asynchronous code (async/await, Promise's) to work. I tried several approaches without much luck:
The two first codes execute without printing anything. The third code hangs due to non-terminating busy waiting.
Note: the codes work correctly in
qjs
(quickjs' interactive prompt), of course replacingprint
withconsole.log
in the first two examples.