Green 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.
Re:JEP 295: Ahead-of-Time Compilation
by icebraining on Thursday October 27, 2016 @06:15PM
(#12810788)
How is the concurrency illusionary?
Re:JEP 295: Ahead-of-Time Compilation
by brianwawok on Friday October 28, 2016 @02:24PM
(#12819167)
Well 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.
Re:JEP 295: Ahead-of-Time Compilation
by icebraining on Friday October 28, 2016 @07:35PM
(#12821679)
Yeah, 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)
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.