1

Are all promise.then methods invoked on the main thread?

Promise().then(async()).then(sync()).then(...)
yunzen
  • 32,854
  • 11
  • 73
  • 106
TommY
  • 738
  • 6
  • 14
  • It's quite general and depends on the environment. – briosheje Dec 19 '18 at 13:07
  • 7
    There invoked on the thread you use them, with Javascript that's normally the main thread, but say with cluster with node, or web workers etc in Browser land it would run in the context you invoked them. This is because Javascript engine is by nature single threaded. But bear in mind, JS API's that are async could process that inside a worker thread, but from your POV it's not relevant. – Keith Dec 19 '18 at 13:15
  • https://stackoverflow.com/a/52444953/1048572, https://stackoverflow.com/q/22844441/1048572, https://stackoverflow.com/a/22254817/1048572 – Bergi Dec 19 '18 at 13:28

0 Answers0