When are threads created for Scala actor's reacts?

后端 未结 4 1254
伪装坚强ぢ
伪装坚强ぢ 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:00

    It is true that for a pure event-based actor, its reacting code runs on the same thread as message sending code.

    But in Scala, since it's not desirable to block a thread when an actor calls a blocking operation inside its react code and to unify event-based and thread-based actors(being able to compose them), both type of actors uses the same thread pool but the thread-based actors get their own threads whereas event-based actors shares threads based on a task queue. For details, please see Actors that Unify Threads and Events by Philipp Haller and Martin Odersky

提交回复
热议问题