Closed qiaoshouzi closed 3 months ago
@qiaoshouzi -
In my expectation, the example code should output like this.
you may not expect that ordering, it is neither specified nor documented.
explanation: when two threads run in parallel, the order in which they finish their execution may or may not be in the order in which the work was assigned or started. complex thread scheduling occur underneath. in addition, the console print is asynchronous, which means an issuance of console.log may not be delivered synchronously.
If maintaining a specific order is a priority, pls avoid multi-threading.
hope this helps!
Details
In my expectation, the example code should output like this.
But in reality, the
parentPort?.postMessage("...")
seems to be executed first, so the output becomes like this.Is this a feature or a bug?
Node.js version
v20.10.0
Example code
Operating system
Win10 22H2
Scope
other
Module and version
worker_threads