When are threads created for Scala actor's reacts?

后端 未结 4 1276
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 14:37

After reading about using react in actors in Scala, I thought react\'s would share the same thread given there weren\'t multiple react\'s

4条回答
  •  春和景丽
    2021-02-15 15:17

    The scheduler library uses a thread pool to control execution of the actors. I don't know the specifics of the logic it uses, but, to me, it would seem natural to expect it to:

    • Initialize with more than one thread in the pool, as multithreaded applications are very likely to use more than one thead.

    • Select the thread to be used with a waiting actor in a queue-like manner -- threads are freed to the end of the queue, and acquire from the beginning of the queue.

    Also, I assume some threads are used to handle the scheduling itself as well as message passing.

提交回复
热议问题