乘法默认调度程序线程的原因是什么

时间:2017-03-16 16:06:07

标签: scala akka

查看我的主题(使用jconsole)我看到很多调度员:

akka.actor.default-dispatcher-...

但是我没有使用Dispatcher创建Actors。什么是多次调度员的原因?

1 个答案:

答案 0 :(得分:0)

来自文档:

  

每个ActorSystem都有一个将在其中使用的默认调度程序   案例没有为Actor配置其他内容。

您在jconsole中看到的是当前提交给默认调度程序的线程。它们的名称为open Akka.FSharp let clusterHostActor = spawn system1 nodeName <| fun (inbox: Actor<_>) -> let cluster = Cluster.Get system1 cluster.Subscribe(inbox.Self, [| typeof<ClusterEvent.IClusterDomainEvent> |]) inbox.Defer(fun () -> cluster.Unsubscribe(inbox.Self)) let rec messageLoop () = actor { let! message = inbox.Receive() match box message with | :? ClusterEvent.MemberUp as event -> printfn "Member %s Joined the Cluster at %O" event.Member.Address.Host DateTime.Now let sref = select (event.Member.Address.ToString() + "/user/listener") inbox sref <! "Hello from clusterHostActor" | :? ClusterEvent.MemberRemoved as event -> printfn "Member %s Left the Cluster at %O" event.Member.Address.Host DateTime.Now | other -> printfn "Cluster Received event %O at %O" other DateTime.Now return! messageLoop() } messageLoop() <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title></title> <style type="text/css"> table td { border-collapse: collapse; } .msoFix { mso-table-lspace: -1pt; mso-table-rspace: -1pt; } </style> </head> <body style="margin: 0px; padding: 0px; background-color: #FFFFFF;" bgcolor="#FFFFFF"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center"> <div style="max-width:640px !important;"> <table class="msoFix" width="320" cellpadding="0" cellspacing="0" align="left" bgcolor="#CCCCCC"> <tr> <td width="290" bgcolor="454545" align="left" style="padding: 0px;"><br>Table 1</td> </tr> </table> <table class="msoFix" width="320" cellpadding="0" cellspacing="0" align="left" bgcolor="#EEEEEE"> <tr> <td width="290" bgcolor="959595" align="left" style="padding: 0px;"><br>Table 2</td> </tr> </table> </div> </td> </tr> </table> </body> </html> 等。它们都由同一个唯一的默认调度程序运行。

default-dispatcher-1调用允许您指定多个调度程序 - 与默认调度程序不同。

更多信息here