The Java™ Tutorials — Concurrency :High Level Concurrency Objects 高并发对象
原文地址:https://docs.oracle.com/javase/tutorial/essential/concurrency/highlevel.html
全文翻译
So far, this lesson has focused on the low-level APIs that have been part of the Java platform from the very beginning. These APIs are adequate for very basic tasks, but higher-level building blocks are needed for more advanced tasks. This is especially true for massively concurrent applications that fully exploit today’s multiprocessor and multi-core systems.
到目前为止,课时都在关注低级别API,它们在一开始就成为了Java平台的一部分。这些API适用于非常基础的任务。但是对于更高级别的任务而言,就需要创建更高级别的构建,有其针对于充分利用了今天的多处理器和多核系统的高并发程序。
In this section we’ll look at some of the high-level concurrency features introduced with version 5.0 of the Java platform. Most of these features are implemented in the new java.util.concurrent packages. There are also new concurrent data structures in the Java Collections Framework.
- Lock objects support locking idioms that simplify many concurrent applications.
- Executors define a high-level API for launching and managing threads. Executor implementations provided by java.util.concurrent provide thread pool management suitable for large-scale applications.
- Concurrent collections make it easier to manage large collections of data, and can greatly reduce the need for synchronization.
- Atomic variables have features that minimize synchronization and help avoid memory consistency errors.
- ThreadLocalRandom (in JDK 7) provides efficient generation of pseudorandom numbers from multiple threads.
本章节中我们将见到在Java 5.0 平台推出的几个高并发特性。大部分这些特性都在新的java.util.concurrent包中实现。在Java集合框架中,也有几种新的并发数据结构。
- Lock对象支持锁的惯用方法,这大大简化了很多并发程序的开发。
- Executor定义了一个高版本API,它可以执行和管理现场。由java.util.concurrent提供的Executor实现支持线程池的管理,这对大型应用十分合适。
- 并发集合让大规模数据集的管理更加简单,并可以大量减少使用同步的需要。
- 原子变量具有最小同步的特性,可用于避免内存一致性错误
- ThreadLocalRandom(于JDK 7推出)提供了多线程下创建伪随机数的高效方法