Creating two or more completely independent threads that run separately from each other is trivial. Just create two instances of the Interpreter, each with its own code, and alternate calling each interpreter's step function.
This demo illustrates the slightly harder problem of creating two threads that share the same global environment. This allows one to share functions and variables, as well as to communicate between threads.
Open your browser's console for errors.
Thread #1 | Thread #2 |
Back to the JS-Interpreter documentation.