亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - Ask a process-related question, js?
僅有的幸福
僅有的幸福 2017-06-12 09:23:56
0
4
729

Declare an empty array, open four processes and push values ??into the array at the same time. What is the order in which the pushes are entered?

僅有的幸福
僅有的幸福

reply all(4)
小葫蘆

I have never heard of the saying that js has multiple processes, and it is impossible to modify an array at the same time. You can post the code for other experts to take a look

三叔

You should write it in NodeJS

學(xué)霸

A simple experiment is as follows. When multiple processes (tasks) operate, the value of the array depends on the last process. I use 2 setTimeout and 1
setInterval to simultaneously operate an array, and push into three values ????1, 2, and 3 respectively. The final result is:

[1, 2, 3, 3, 1, 1, 3, 1, 1, 3]

There is a clear explanation in Ruan Yifeng’s article: Single thread means that all tasks need to be queued, and the next task will not be executed until the previous task is completed. If the previous task takes a long time, the next task will have to wait. ;View original text

typecho

Just test it and you will know. Print this array every time the push is successful

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template