From the course: JavaScript: Web Workers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

How the browser works with threads

How the browser works with threads - JavaScript Tutorial

From the course: JavaScript: Web Workers

Start my 1-month free trial

How the browser works with threads

- [Instructor] To understand how the browser works in terms of threading, let's analyze another code that we have here on the screen. Let's say that we have a setInterval that's a function that executes, or it seems like it's executing, the code every 200 milliseconds. So that's the idea. I have a code here that every 200 milliseconds, it's making a calculation, and after that it's changing some HTML and some CSS properties. So we are expecting that to appear on the screen every 200 milliseconds, they change. Also we have a button somewhere, and we have a click handler. And that click handler, we are looping through a collection and making some heavyCalculation on the collection. So similar to the previous example that we saw on capital series. So, when we look at that code, we know that JavaScript and the browser use concurrency. So when we look at that code, we think that we can execute several tasks concurrently. So when we think about the diagram, we think about this. So we have…

Contents