【翻译十七】java-并发之高性能对象
High Level Concurrency Objects
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.
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平台的API.这些API对于一些基本的任务,但是高性能的程序块对于一些更高级的任务来说是需要的。这个尤其是对于当今多处理器和多核系统需要处理高并发的应用程序。
在这一节我们将会看到许多java 5.0中引进的高性能的并发特性。许多这些特性都在 java.util.concurrent包中。这里也还有些并发的数据结构在java集合框架中。
- 锁对象,适用于许多并发程序的锁对象条目
- 执行性器,定义一个能载入和管理线程的高性能的API。执行器由java.util.concurrent提供,
- 提供对于大规模应用程序的线程池管理。
- 并发集合,使管理并发的数据集更加容易,并且能够有效的减少synchronization的需求。
- 原子性变量,具有最小的同步特性并能有效的避免内存一致性错误。
- 本地随机线程(JDK 7)对于多线程提供有效的生成伪随机数的方法。