Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!