3 ms·
Green threads are very different from system threads. With green threads you get an illusion of concurrency, and when coding you need to account that multiple g
by takeda 10y ago
Green threads are very different from system threads. With green threads you get an illusion of concurrency, and when coding you need to account that multiple green threads work on a single system thread.
There's no way you would get a switch like that, because you interact with them differently. I wish greenthreads would not use "thread" in the name because it causes confusion like in your case.
- icebraining 10y agoHow is the concurrency illusionary?
- brianwawok 10y agoWell a System with 16 CORE / 32 Hardware threads.. you run a program with 32 threads, you can legit run 32 things in parallel. Now not really because of OS scheduling and logs and other junk going on, but it could actually happen. You take the same code and run it with 3000000 green threads... you are still capped out at 32 things running at the same time. Your system can kinda sorta pretend to be more concurrent, but the actually concurrency is the same.
- icebraining 10y agoYeah, but you could also have thousands of system (OS) threads in that same hardware, and they wouldn't run at the same time either. (Also, they're still concurrent, just not parallel: https://vimeo.com/49718712 https://vimeo.com/49718712)
- logn 10y agoGreen threads and system threads are the same illusion to programmers (or, at least, they can be). The only caveat is that dependencies using system threads won't play nicely with green threaded code. Quasar, which does green threads for Java, schedules and distributes your green threads to system threads, one for each cpu. The Quasar API for green threads is basically identical to built in Java APIs.