//Listing 6-3. Using an Exchanger to Swap Buffers import java.util.ArrayList; import java.util.List; import java.util.concurrent.Exchanger; public class ExchangerDemo { final static Exchanger<DataBuffer> exchanger = new Exchanger<DataBuffer>()…
一.简介 Exchanger是自jdk1.5起开始提供的工具套件,一般用于两个工作线程之间交换数据.在本文中我将采取由浅入深的方式来介绍分析这个工具类.首先我们来看看官方的api文档中的叙述: A synchronization point at which threads can pair and swap elements within pairs. Each thread presents some object on entry to the exchange method, mat…