Reputation: 11
I have done some research because I need to know how multithreading works in javascript, but I'm still missing some things. I have a question:
If I have for example 4 cores in my CPU and I want to run 2 javascript scripts in 2 different tabs in a browser (e.g. in chrome - does it matter if it's chrome or firefox?) is it possible to run them both at the same time using 2 cores?
If the answer is yes - do I need to use Web Workers?
Any help would be appreciated.
Upvotes: 0
Views: 125
Reputation:
You can multithread in JavaScript using Web Workers. You won't need to open other tabs, but you will likely need to have separate JavaScript files.
Most browsers other than IE support web workers. IE supports it in v10+. In the past when I implemented web workers, I used web workers client side when available, and fell back to having my web server do the processing otherwise using AJAX as an interface.
Good luck :)
Upvotes: 2