生产者消费模式:
生产者生产数据到缓冲区中,消费者从缓冲区中取数据。
如果缓冲区已经满了,则生产者线程阻塞;
如果缓冲区为空,那么消费者线程阻塞。
特点是当多个消费者监听消息队列,一旦消息到达,消费者马上消费,谁先抢到算谁的,如果队列里没有消息,则消费者继续监听。
发布订阅者(观察者)模式:
和生产者消费模式有点像,但是多个消费者(观察者)订阅消息频道,只要发布者发布消息,所有订阅者都能收到消息,订阅者都是平等的。