Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the electron framework allow multi-threading through web workers?

Tags:

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?

like image 423
smuggledPancakes Avatar asked Apr 29 '16 15:04

smuggledPancakes


1 Answers

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().

like image 103
Vadim Macagon Avatar answered Oct 20 '22 07:10

Vadim Macagon