Event Loop Starvation
NodeJS
Hard
5 views
Problem Description
Show how a long sync loop blocks timers (print before and after).
Output Format
Print lines.
Constraints
Keep loop small but visible.
Official Solution
setTimeout(() => console.log('timer'), 0);
console.log('start');
let x = 0;
for (let i = 0; i < 3e7; i++) x += i;
console.log('after loop');
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!