Javascript event handlers in Chrome would be executed in parallel?
<p>Javascript is single-threaded, that means all event handlers are executed without interrupts, all handlers are executed sequentially, one-by-one. That is true in all my previous experiences, until I encounter the following code snippets.</p>

<p>I write the following codes, and executed in <strong>Chrome</strong> (version 51.0.2704.103 m (64-bit))</p>

<pre><code>let port = chrome.runtime.connect("appid");
port.onMessage.addListener(function (msg: string) {
    console.log("enter");
    for (let i = 0; i &lt; 9999999; ++i) { }
    console.log("leave");
});
</code></pre>

<p>The other-side (corresponding to the appid) would send 2 messages through that port.</p>

<p>In normal execution (without setting breakpoint in Chrome devtools), the console output is:</p>

<pre><code>enter
leave
enter
leave
</code></pre>

<p>that is perfect. However, if I set a breakpoint at console.log("enter"); in the Chrome devtools, the console output is:</p>

<pre><code>enter
enter
leave
</code></pre>

<p>It seems that the Chrome does not stop at the breakpoint, still accepts the second message and run. Is there more than 1 thread in Chrome to handle Javascript events? And in which situation that I should consider the Javascript codes would not run sequentially?</p>