Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
Javascript Webworkers and Multithreading

Do all javascript webworkers for a page operate on a single separate thread from the main page, or does each webworker get its own thread? For context: I have a large amount of data that is currently being processed by one webworker. Would it be faster to split it up across 10 webworkers, or will they all use the same thread?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

That is not defined by the standard:

This standard does not define the precise mechanism by which this is achieved, be it time-sharing cooperative multitasking, fibers, threads, processes, using different hyperthreads, cores, CPUs, machines, etc.

Even if each webworker gets its own thread, the CPU is not able to run them in parallel, if the number of cores is lower then the number of web workers. Also other threads are using the CPU.

Web workers have not exactly been made for you scenario. They are more of a 'don't block the UI' thing. See also this statement from the standard:

Workers (as these background scripts are called herein) are relatively heavy-weight, and are not intended to be used in large numbers

The only sensible thing to do is to test what works best (with all relevant browsers). You can check self.navigator.hardwareConcurrency (see here) in your code to decide how many workers you should spawn.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda