我们应该何时使用Java的Thread over Executor? [英] When should we use Java's Thread over Executor?

查看:144
本文介绍了我们应该何时使用Java的Thread over Executor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行器看起来像一个干净的抽象。什么时候你想直接使用Thread而不是依赖更健壮的执行器?

Executor seems like a clean abstraction. When would you want to use Thread directly rather than rely on the more robust executor?

推荐答案

作为Java 1.5中的Java标准的一部分添加。因此在某些方面Executors可以被视为一个新的更好的抽象处理Runnable任务。

To give some history, Executors were only added as part of the java standard in Java 1.5. So in some ways Executors can be seen as a new better abstraction for dealing with Runnable tasks.

一个过度简化来了... - Executors是线程完成因此优先使用它们。

A bit of an over-simplification coming... - Executors are threads done right so use them in preference.

这篇关于我们应该何时使用Java的Thread over Executor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆