电子框架是否允许通过网络工作者进行多线程? [英] Does the electron framework allow multi-threading through web workers?

查看:11
本文介绍了电子框架是否允许通过网络工作者进行多线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我制作了一个电子应用程序,我很难在谷歌上搜索我将如何进行多线程.会是网络工作者吗?

I am having a hard time googling how I would do multi-threading if I made an electron app. Would it be with web workers?

推荐答案

在渲染进程中你可以创建Web Workers,并且这些将在自己的线程中运行,但是 在这些 Web Workers 中将禁用节点集成 因为 Node 不是线程安全的.因此,如果您想在使用 Node 的单独线程中运行某些东西,那么您需要生成一个单独的进程,您可以使用 child_process.fork() 然后使用 send().

In the renderer process you can create Web Workers, and those will run in their own threads, however Node integration will be disabled in those Web Workers because Node isn't thread-safe. So if you want to run something in a separate thread that uses Node then you'll need to spawn a separate process, you can do so with child_process.fork() and then communicate with the new process using send().

这篇关于电子框架是否允许通过网络工作者进行多线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆