DEV Community

Ben Lovy
Ben Lovy

Posted on

Some people try to solve problems using threads...

And then two they hav erpobl.esms

Top comments (6)

Collapse
 
prahladyeri profile image
Prahlad Yeri • Edited

I agree. Multi-threading introduces a lot more complexity to your app than needed, so they should be used sparingly and only as the very last resort.

In fact, async I/O is what you need most of the time when you think that you need multi-threading. Consider that JavaScript on server side is so fast compared to traditional interpreters like PHP/Python only because of async I/O and it doesn't even need multi-threading!

Collapse
 
elmuerte profile image
Michiel Hendriks

Multi threading processing only introduces more complexity when you have mutable data.

async I/O does not solve problems which require multi threading to be solved, it solves an other problem which is made worse with multi threading. You need both; multi threading and async I/O.

Collapse
 
qm3ster profile image
Mihail Malo

Real multithreading is much better than "clustering". You just need a borrow checker :v

Collapse
 
karataev profile image
Eugene Karataev

Sometimes async I/O is not enough.
What about heavy CPU calculations? It'll block the main thread and make the application unresponsive. That's why Workers were introduced in Node 10.5.

Collapse
 
anuragrana profile image
Anurag Rana • Edited
  • 3. things
  • 1. five
  • 5. asynchronous programming
  • 4. about
  • 2. good
Collapse
 
theodesp profile image
Theofanis Despoudis

There is a solution for that. A React useThread hook.