繁体   English   中英

ExecutorCompletionService核心Java类中使用的设计模式

[英]Design pattern used in ExecutorCompletionService core java class

ExecutorCompletionService是Executor和ExecutorService类的包装器。 通过查看ExecutorCompletionService类源代码,我可以想到许多设计模式

public class ExecutorCompletionService<V> implements CompletionService<V>
{
    public ExecutorCompletionService(Executor executor) {
    }
}
  • 代理设计模式
  • 适配器设计模式
  • 装饰器设计模式
  • 桥梁设计模式

谁能详细解释我们可以对此类实现进行分类的设计模式? 提前致谢。

ExecutorCompletionService不在身边的包装Executor ,它是一个实现CompletionService使用一个Executor做其工作。

Executor是通过构造函数注入的,而不是在内部创建的,这是依赖反转的应用程序。

同样,它也可以接受外部BockingQueue实现,以用于执行已完成的任务,但这并不能使其成为BockingQueue的包装器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM