Scala中的Akka,感叹号和问号 [英] Akka in Scala, exclamation mark and question mark
本文介绍了Scala中的Akka,感叹号和问号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
向Actor发送消息时,感叹号(!
)和问号(?
)有什么区别?
What is the difference between exclamation mark (!
) and question mark (?
) when sending messages to Actors?
myActor ! Hello(value1)
myActor ? Hello(value1)
推荐答案
Shamelessly copied [awesome] official doc (look Send messages section for more):
通过以下方法之一将消息发送给Actor.
Messages are sent to an Actor through one of the following methods.
!
的意思是一劳永逸",例如异步发送消息,
立即返回.也称为tell
.
!
means "fire-and-forget", e.g. send a message asynchronously and
return immediately. Also known as tell
.
?
发送一条消息
异步返回Future
表示可能的答复.
也称为ask
.
?
sends a message
asynchronously and returns a Future
representing a possible reply.
Also known as ask
.
这篇关于Scala中的Akka,感叹号和问号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文