观察者模式是软件设计模式的一种。在此种模式中,一个目标对象管理所有相依于它的观察者对象,并且在它本身的状态改变时主动发出通知。这通常透过呼叫各观察者所提供的方法来实现。此种模式通常被用来实时事件处理系统。
Array(
=> Subject Math was included => The Student Rafael was included => The Student Vinicius was included => The Teacher Marcus Brasizza was included => The Student Rafael was removed => Comes from Vinicius: I'm a student of Math => Comes from Marcus Brasizza: I teach in Math
)
Second Subject
Array(
=> Subject English was included => The Teacher Renato was included => The Student Vinicius was included => The Student Fabio was included => The Student tiago was included => Comes from Renato: I teach in English => Comes from Vinicius: I'm a student of English => Comes from Fabio: I'm a student of English => Comes from tiago: I'm a student of English
)
亦可参考https://web.archive.org/web/20100330025802/http://www.javaworld.com/javaworld/javaqa/2001-05/04-qa-0525-observer.html