How to activate two JavaScript functions in parallel?

前端 未结 7 866
失恋的感觉
失恋的感觉 2020-12-16 02:23

Anyone can tell me how to activate two (or more) JavaScript AJAX functions in parallel?

7条回答
  •  难免孤独
    2020-12-16 02:46

    Javascript runs as a single thread, if the requests that you want to make doesn't have an IO, In that case its just not possible, if there's an IO operation involved, you can very well execute the two functions one after the other, the very nature of javascript will start executing the next function when it waits for IO. Usually in languages that support threading the same thing is achieved automatically during the CPU rest period for a thread.

提交回复
热议问题