回调函数的理解

<strong>问:你有事去隔壁寝室找同学,发现人不在,你怎么办呢?</strong>
<strong>方法1</strong>,每隔几分钟再去趟隔壁寝室,看人在不
<strong>方法2</strong>,拜托与他同寝室的人,看到他回来时叫一下你

前者是轮询,后者是回调。

要是你去等他,就把原来的非阻塞的异步调用变成了阻塞的同步调用。

 

回调函数到底是什么

A callback is a function that is passed as an argument to another function and is 
executed after its parent function has completed.

  https://www.jianshu.com/p/6bc353e5f7a3

posted @ 2018-09-06 15:32  芥末的糖  阅读(99)  评论(0编辑  收藏  举报