This time around, we’re requesting the homepage for Google.com and, at the same time, sorting a randomly generated array of 1 million numbers. This is going to take a few seconds, so it’s perfect for us to show how well this behaves. We’re also going to measure the time it takes for the worker thread to perform the sorting and we’re going to send that value (along with the first sorted value) to the main thread, where we’ll display the results.A few days ago, version 10.5.0 of Node.js was released and one of the main features it contained was the addition of initial (and experimental) thread support.
This is interesting, especially coming from a language that’s always prided itself on not needing threads thanks to it’s fantastic async I/O. So why would we need threads in Node?