Why can't Web Worker call a function directly?

前端 未结 7 1058
借酒劲吻你
借酒劲吻你 2021-02-01 03:15

We can use the web worker in HTML5 like this:

var worker = new Worker(\'worker.js\');

but why can\'t we call a function like this?



        
7条回答
  •  北荒
    北荒 (楼主)
    2021-02-01 03:27

    By design web workers are multi-threaded, javascript is single threaded"*"multiple scripts cannot run at the same time.

    refer to: http://www.html5rocks.com/en/tutorials/workers/basics/

提交回复
热议问题