简体   繁体   English

Akka Actor和Java Thread之间的关系?

[英]Relationship between akka Actor and Java Thread?

I am trying to get my head around Akka and onething which I am not able to visualize is the relation between Java Threads to Akka Actors 我试图绕过Akka,我无法想象的是Java线程与Akka Actors之间的关系

  • is it 1:1 ? 1:1吗?
  • is it 1:many ? 1:many吗?

I am confused with it now 我现在很困惑

Akka actors (usually) do not have a fixed thread assigned to them. Akka演员(通常)没有分配固定的线程。 Threads are assigned to messages. 线程被分配给消息。

The dispatcher assigns threads to messages which are polled from the mailbox. 调度程序将线程分配给从邮箱轮询的邮件。 He decides when each actor can start processing a message. 他决定每个演员何时可以开始处理消息。 When the actor has an empty mailbox, he owns no thread. 当演员的邮箱为空时,他没有线程。 The number of threads per dispatcher is configurable. 每个调度程序的线程数是可配置的。

Though there is a dispatcher called the "pinned dispatcher", which gives one fixed thread to each actor, it is rarely used. 尽管有一个称为“固定调度程序”的调度程序,该调度程序为每个actor提供了一个固定线程,但很少使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM