我们什么时候应该使用 Java 的 Thread 而不是 Executor? [英] When should we use Java's Thread over Executor?

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

问题描述

Executor 似乎是一个干净的抽象.你什么时候想直接使用 Thread 而不是依赖更健壮的执行器?

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

推荐答案

为了说明历史,Executors 仅作为 Java 1.5 中的 Java 标准的一部分添加.所以在某些方面 Executor 可以被看作是处理 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 而不是 Executor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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