qk_pro
Senior Member
Bản chất thì multithread hay không nó không phụ thuộc vào language, mà phụ thuộc vào runtime/compiler nhé các anh. C ko dùng mấy cái lib kiểu pthread thì cũng ko multithread đc, mà sau này ông nào rảnh làm cái runtime hỗ trợ cho javascript create thread mutex các kiểu thì js nó cũng là multithread thôi
Không hẳn. Về cơ bản cái spec của ngôn ngữ được viết ra với tư tưởng của event loop / queue nên nếu muốn implement được 1 cái runtime hỗ trợ "explicit multi-threading" thì phải sửa lại spec của cả ngôn ngữ
https://262.ecma-international.org/6.0/#sec-executable-code-and-execution-contexts
đoạn mục 8.3 , 8.4
"An execution context is a specification device that is used to track the runtime evaluation of code by an ECMAScript implementation. At any point in time, there is at most one execution context that is actually executing code. This is known as the running execution context. A stack is used to track execution contexts. The running execution context is always the top element of this stack. A new execution context is created whenever control is transferred from the executable code associated with the currently running execution context to executable code that is not associated with that execution context. The newly created execution context is pushed onto the stack and becomes the running execution context."
"More than one job may be in progress at the same time, but only one job in a given job queue is executed at a time. Once a job is started the ECMAScript implementation controls its completion and the selection of the next job to be initiated from the queue."