Why doesn't Ruby have a ThreadPool built-in?

前端 未结 3 764
隐瞒了意图╮
隐瞒了意图╮ 2021-02-03 13:38

I have a program that creates 10000 threads at once, and runs 8 at the same time.

But ruby doesn\'t have a ThreadPool built-in as Java. Is there a good reason?

3条回答
  •  太阳男子
    2021-02-03 14:23

    My suspicion would be it's because a ThreadPool wouldn't be that useful in C-based implementations of Ruby. You can use only one processor at a time with Matz's Ruby Intepreter or Yet Another Ruby VM.

    If you want multiple threads to be run on multiple processors, you need to use JRuby instead.

提交回复
热议问题