The Java™ Tutorials — Concurrency :Thread Objects 线程对象
原文地址:https://docs.oracle.com/javase/tutorial/essential/concurrency/threads.html
关键点
- 线程管理的抽离:利用Executor
- 实现线程管理的直接控制:线程和异步任务的配套创建
全文翻译
Each thread is associated with an instance of the class Thread. There are two basic strategies for using Thread objects to create a concurrent application.
- To directly control thread creation and management, simply instantiate Thread each time the application needs to initiate an asynchronous task.
- To abstract thread management from the rest of your application, pass the application’s tasks to an executor.
每个线程都和一个Thread类的实例相关联。使用Thread对象创建并发程序时,有两个基本的策略:
- 为了直接控制线程的创建和管理,每次简单地实例化一个Thread对象时,应用也需要创建一个异步任务。
- 为了把线程管理从你应用的其他部分抽象出来,你需要把应用的任务传给一个executor对象
This section documents the use of Thread objects. Executors are discussed with other high-level concurrency objects.
本章节记录了Thread对象的使用。Executor会同其他高版本并发编程对象一起讨论。