My personal understandingJavaScript is a single thread. Using setinterval is to add things to this single thread regularly. Then I use two setintervals to request two different data interfaces, so there will be no concurrency. I request data in queue order. So why is there a jam when using setinterval to request data interfaces,What, carton? The network is pending? Or page Caton?
How do you write setinterval? What effect do you want to achieve?
It’s best to post the corresponding code for analysis,JS multithreading requires the cooperation of web workers. How many setintervals are written will not cause multithreading. All tasks will be queued in turn. Page jams are simply cyclic calls that are too frequent or the interface is too slow.,JS
The way to deal with asynchronous tasks is similar to that when you wait for the rice to be stewed in an electric rice cooker, you can fry instead of waiting for the rice to be stewed.
But your ability is limited after all. If you are allowed to stew dozens of pots of rice, the rice here has not been washed, and the rice there has been burnt. At this time, you will be “stuck”.setInterval + XHRHTTPRequest
It’s like asking you to stew another pot of rice every few minutes. The number of concurrent requests on the same page and domain name is limited. Chrome seems to have six requests, which means you only have six rice cookers, but the task of cooking has been increasing.
What, carton? The network is pending? Or page Caton?
How do you write setinterval? What effect do you want to achieve?
It’s best to post the corresponding code for analysis
JS multithreading requires the cooperation of web workers. How many setintervals are written will not cause multithreading. All tasks will be queued in turn. Page jams are simply cyclic calls that are too frequent or the interface is too slow.
JS
The way to deal with asynchronous tasks is similar to that when you wait for the rice to be stewed in an electric rice cooker, you can fry instead of waiting for the rice to be stewed.
But your ability is limited after all. If you are allowed to stew dozens of pots of rice, the rice here has not been washed, and the rice there has been burnt. At this time, you will be “stuck”.setInterval + XHRHTTPRequest
It’s like asking you to stew another pot of rice every few minutes. The number of concurrent requests on the same page and domain name is limited. Chrome seems to have six requests, which means you only have six rice cookers, but the task of cooking has been increasing.
I’ll delete it if I don’t add any more
Please use the comment function
Questions should be put in comments, not in answers.
@fenYes, it is executed at the terminal
Please ignore this article