How does single-threaded JS implement multiple interactions at the same time

海洋饼干
中文

Answer: Simulate multi-threading with "rotary time slices" (segments that perform multiple tasks in turn in a short period of time)

Method to realize:

  1. Existing task 1, task 2
  2. Split task 1 and task 2
  3. Randomly arrange these task fragments to form a queue
  4. Send the task fragments to the JS engine in this queue order
  5. The JS engine executes these task fragments in turn
阅读 606

饼干陪你一起玩前端
爱思考,爱分享
1.5k 声望
176 粉丝
0 条评论
1.5k 声望
176 粉丝
文章目录
宣传栏