mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-11-01 03:23:42 +00:00
Update 设计模式 - 观察者.md
补充观察者同步调用的注意事项及 Spring 事件相关说明,对参考文献进行文字校对。
This commit is contained in:
+3
-1
@@ -123,6 +123,8 @@ CurrentConditionsDisplay.update: 1.0 1.0 1.0
|
||||
StatisticsDisplay.update: 1.0 1.0 1.0
|
||||
```
|
||||
|
||||
需要注意的是,notifyObserver() 在调用 setMeasurements() 的线程中依次同步调用每个观察者,一个观察者耗时过长或抛出异常,后面的观察者就会被拖慢或收不到通知。Spring 事件中的同样问题和解决办法见[Spring 中的设计模式](Spring.md#七spring-中的设计模式)。
|
||||
|
||||
### JDK 中的应用
|
||||
- [java.util.Observer](http://docs.oracle.com/javase/8/docs/api/java/util/Observer.html)(JDK 9 起已废弃)
|
||||
- [java.util.EventListener](http://docs.oracle.com/javase/8/docs/api/java/util/EventListener.html)
|
||||
@@ -132,4 +134,4 @@ StatisticsDisplay.update: 1.0 1.0 1.0
|
||||
## 参考资料
|
||||
|
||||
- 弗里曼. Head First 设计模式 [M]. 中国电力出版社, 2007.
|
||||
- Gamma E. 设计模式: 可复用面向对象软件的基础 [M]. 机械工业出版社, 2007.
|
||||
- Gamma E. 设计模式:可复用面向对象软件的基础 [M]. 机械工业出版社, 2007.
|
||||
|
||||
Reference in New Issue
Block a user