Running code inside another thread in javascript

后端 未结 4 1316
-上瘾入骨i
-上瘾入骨i 2021-02-07 09:18

I want to seperate thread on the page to prevent freezing of gui. For this, I am running the function which will freeze gui inside another thread with setTimeout but still freez

4条回答
  •  囚心锁ツ
    2021-02-07 09:42

    javascript(browser) is a single thread application, so even if you use a setTimeout at any point of time there will be only one thread running(doing script execution, ui repainting etc). Read more about how the timers work here

    Since you have a script running in every millisecond it will freeze up the thread thus blocking the UI

提交回复
热议问题