<story><title>Populating the page: how browsers work (2020)</title><url>https://developer.mozilla.org/en-US/docs/Web/Performance/How_browsers_work</url></story><parent_chain><item><author>danielvaughn</author><text>My understanding is that single-thread concurrency is essentially what Javascript does. It basically flickers between tasks very rapidly to simulate concurrency. Does that match your understanding or am I incorrect?</text></item><item><author>Lukeisun</author><text>Concurrency can be done on a singular thread</text></item><item><author>bloopernova</author><text>That was really informative, but it raised a question for me:&lt;p&gt;It described the browser as single threaded, but then talked about multiple concurrent tasks. Aren&amp;#x27;t those threads?&lt;p&gt;One more question: are there any browsers that use multiple threads to lay out the various object models and render the page? If it&amp;#x27;s been found to be too difficult, what were the issues?</text></item></parent_chain><comment><author>euiq</author><text>I don&amp;#x27;t think that &amp;quot;flickers between tasks very rapidly to simulate concurrency&amp;quot; is a good mental model for event loops. It&amp;#x27;s more like &amp;quot;runs one task at a time until it hits a suspension point,&amp;quot; where a suspension point is something like an I&amp;#x2F;O operation. If you had an event loop that switched tasks between suspension points, then you&amp;#x27;d still need locks for shared data.</text></comment>
<story><title>Populating the page: how browsers work (2020)</title><url>https://developer.mozilla.org/en-US/docs/Web/Performance/How_browsers_work</url></story><parent_chain><item><author>danielvaughn</author><text>My understanding is that single-thread concurrency is essentially what Javascript does. It basically flickers between tasks very rapidly to simulate concurrency. Does that match your understanding or am I incorrect?</text></item><item><author>Lukeisun</author><text>Concurrency can be done on a singular thread</text></item><item><author>bloopernova</author><text>That was really informative, but it raised a question for me:&lt;p&gt;It described the browser as single threaded, but then talked about multiple concurrent tasks. Aren&amp;#x27;t those threads?&lt;p&gt;One more question: are there any browsers that use multiple threads to lay out the various object models and render the page? If it&amp;#x27;s been found to be too difficult, what were the issues?</text></item></parent_chain><comment><author>eyelidlessness</author><text>It doesn’t simulate, and the “flicker” is named “event loop”, but otherwise you’ve got it right. The concurrency model is essentially cooperative, ie pending tasks wait for the current task on the event loop to unblock, and then they are each executed in turn (with several different scheduling priorities based on how they became pending, eg synchronous event callbacks, Promises, various timers).</text></comment>