UI responsiveness and javascript

前端 未结 4 1776
被撕碎了的回忆
被撕碎了的回忆 2020-12-30 16:53

I have a large set of data to be plotted on google map. Because of the data set size, google map always freezes for a few seconds before all the points are plotted. I used a

4条回答
  •  囚心锁ツ
    2020-12-30 17:32

    Javascript might not support multiple threads normally, but you can achieve the effect.

    function spawnThread(func, params){
       window.setTimeout(
          (function(f, p){
            return function(){
              f.call(p);
            }
          )(func, params), 0
       )
     }
    

    The main problem with this method would, of course, be checking on the success of the thread, I assume you could manage this using a global variable or something similar, wouldn't be a great solution, but it would work.

提交回复
热议问题