Does an asynchronous call always create/call a new thread?

后端 未结 6 1778
迷失自我
迷失自我 2020-12-04 17:45

Does asynchronous call always create a new thread?

Example:

If JavaScript is single threaded then how can it do an async postback? Is it actually blocking u

6条回答
  •  误落风尘
    2020-12-04 18:32

    No, but more than one thread will be involved.

    An asynchronous call might launch another thread to do the work, or it might post a message into a queue on another, already running thread. The caller continues and the callee calls back once it processes the message.

    If you wanted to do a synchronous call in this context, you'd need to post a message and actively wait for the callback to happen.

    So in summary: More than one thread will be involved, but it doesn't necessarily create a new thread.

提交回复
热议问题