Message from JavaScript discussions

December 2018

— It's a trick

— 

const logForever = n => {
while (true) console.log(n);
};


make logForever run concurrently with itself, logging:
1
2
1
2
1
2

— How do you decide to do this without hertz?

— Pretty simply, recursive setTimeout

— With hertz:

spawn logForever(1);
spawn logForever(2);

— Its when your code scales up when that becomes costly

— Without changing the implementation of logForever

— Ah, right, you would have to without hz

— Using setTimeout inside logForever breaks the point

— Because the point is to make synchronous code concurrent

— Right, so what hz does is "simulate" threads, that is what N:1 thread model is... it means running N 'simulated" threads on 1 real OS thread

Message permanent page

— Hertz gives you threads in the browser too