Both setTimeout and web worker more or less do the same thing. They make the main thread non-blocking and does it's work asynchronously in the background. How do we judge when to use what?
They make the main thread non-blocking and does it's work asynchronously in the background.
No. They don't. That's what a Web Worker does.
setTimeout puts a function on a queue to be run later. When it runs it still runs on the main thread and is just as blocking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With