CSUMB - Week 5
Author
Date Published

MULTI-THREADING
(but actually for real)
So for some context, I have been programming in javascript for something like 7 years at this point so my understanding of multi-threading is clearly spoiled a bit. Honestly, I kinda thought using `fork()` in node was valid multi-threading in javascript. It turns out, while yes technically forking a process does allow an application as a whole to use more threads, it actually just creates an entirely new execution program. Like it spins up another version of node with whatever javascript you want to run and adds some extra data channels to pass data back and forth.
Node kind of has the ability to manage threads with workers but, I am getting away from the point of this class. C has the ability to access the OS's multi-threading API (Pthreads for unix based systems and Windows Threads on Windows). This allows the programmer to leverage threads with the extremely minimal over head but, (and this is a big but) OS level threads are able to share memory which requires the programmer to be diligent about locking and unlocking their threads so that the program behaves in an expected way.
I am realizing exactly how much the Javascript ecosystem I have been programming in is like a playground designed by insurance companies to make sure I can do what I need to get done while causing the least amount of headache possible. C on the other hand feels like I am given the tools to do anything... I just have to learn how to use them better.
Comments
Join the conversation! Login to reply to comments