摘要: 要实现一个增强版的线程安全类,有很多方法,但是目前我所知道最好的是使用组合方法。比如要在线程安全的List中增加put-if-absent功能,可以这样:@ThreadSafepublic class ImprovedList<T> implements List<T> {private final List<T> list;public ImprovedList(List<T> list) { this.list = list; }public synchronized boolean putIfAbsent(T x) {boolean con 阅读全文
posted @ 2011-08-15 17:13 freewater 阅读(193) 评论(0) 推荐(0) 编辑