Sharing variables between web workers? [global variables?]

前端 未结 4 469
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-17 19:06

Is there any way for me to share a variable between two web workers? (Web workers are basically threads in Javascript)

In languages like c# you have:



        
4条回答
  •  庸人自扰
    2021-01-17 19:19

    No, but you can send messages to web workers which can be arrays, objects, numbers, strings, booleans, and ImageData or any combination of these. Web workers can send messages back too.

提交回复
热议问题