Python, Ruby, Haskell - Do they provide true multithreading?

后端 未结 8 658
我寻月下人不归
我寻月下人不归 2021-02-01 22:31

We are planning to write a highly concurrent application in any of the Very-High Level programming languages.

1) Do Python, Ruby, or Haskell support true multithreading?

8条回答
  •  悲哀的现实
    2021-02-01 22:57

    The Haskell implementation, GHC, supports multiple mechanisms for parallel execution on shared memory multicore. These mechanisms are described in "Runtime Support for Multicore Haskell".

    Concretely, the Haskell runtime divides work be N OS threads, distributed over the available compute cores. These N OS threads in turn run M lightweight Haskell threads (sometimes millions of them). In turn, each Haskell thread can take work for a spark queue (there may be billions of sparks). Like so: enter image description here

    The runtime schedules work to be executed on separate cores, migrates work, and load balances. The garbage collector is also a parallel one, using each core to collect part of the heap.

    Unlike Python or Ruby, there's no global interpreter lock, so for that, and other reasons, GHC is particularly good on mulitcore in comparison, e.g. Haskell v Python on the multicore shootout

提交回复
热议问题