代码中的设计模式

策略模式

ThreadPoolExecutor的RejectedExecutionHandler,实现不同的拒绝策略。

装饰者模式

BufferedInputStream对InputStream扩展buffer功能。

工厂模式

Executors作为工厂,提供各种ExecutorService。

命令模式

Runnable。线程池将Runnable任务放入队列,由worker线程调用执行。

模板方法模式

Collections.sort对象需要实现Comparable接口的compareTo方法。

责任链模式

ChannelPipeline中每个channelHandler处理read,write。
各种handle failures pipeline, accessing data pipeline。

享元模式

lucene写数据时,线程从segment池中获取segment。

原文地址:https://www.cnblogs.com/vsop/p/12731373.html