! 的源代码:

def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit

tell 的源代码:

final def tell(msg: Any, sender: ActorRef): Unit = this.!(msg)(sender)

forward 的源代码:

def forward(message: Any)(implicit context: ActorContext) = tell(message, context.sender())

通过源代码。我们能够轻而易举的知道 :

!  发送的消息的发送者通过一个隐式转换,把一个ActorRef转换成sender,假设找不到ActorRef的话。那个发送者就是noSender。

forward 发送消息的发送者是当前消息的上一个发送者。

即:

A To B, B To C

假设通过!

的方式发送消息,则C接收到的消息的发送者是B.

假设通过 forward 的方式发送消息。则C接收到的消息的发送者是A.

假设希望 !的方式发送消息的同一时候携带发送者消息,则能够使用  .!(msg)(sender)

假设希望关掉actor,直接shutdown或者使用父亲actor的stop。在actor内部还能够使用context.stop(self)

最新文章

  1. [LeetCode] Patching Array 补丁数组
  2. 抓包工具Wireshark过滤器
  3. CentOS6.5恢复误删除的文件
  4. c/s模式 (C#)下Ftp的多文件上传及其上传进度
  5. oracle rownum paging issues
  6. Sql 邮件发送
  7. for循环的嵌套
  8. 在ScrollView中嵌入GridView
  9. Android 从java字节码告诉你 为什么Handler会造成内存泄露
  10. WinForm开发中针对TreeView控件改变当前选择节点的字体与颜色
  11. C# 实体model验证输出
  12. 在 iOS 应用中直接跳转到 AppStore 的方法--备用
  13. SuperMap
  14. /proc/uptime
  15. QT中定时器的使用方法
  16. systemd的作用
  17. UDP 单播、广播、多播
  18. 剑指offer编程题Java实现——面试题7相关题用两个队列实现一个栈
  19. Linux_free(buffer与cache区别)
  20. Android的四大组件学习

热门文章

  1. 【剑指offer】面试题 15. 二进制中 1 的个数
  2. es6字符串、数值、Math的扩展总结
  3. Linux下使进程在后台运行
  4. python初步入门
  5. 【转载】SwipeRefreshLayout源码解析
  6. Spring Cloud Feign 总结
  7. js中复制方法总结
  8. 静态call 动态call LINK
  9. Xamarin Android项目提示SDK版本太老
  10. AtCoder - 3939 Strange Nim