Java Reference
In-Depth Information
TransferQueue is a subinterface of BlockingQueue and describes a
blockingqueueinwhichproducersmaywaitforconsumerstoreceiveelements.
The LinkedTransferQueue class implements this interface.
ConcurrentLinkedDeque is an unbounded concurrent deque based on
linked nodes.
ConcurrentLinkedQueue isanunboundedthread-safeFIFOimplementa-
tion of the Queue interface.
ConcurrentSkipListSet is a scalable concurrent NavigableSet im-
plementation.
CopyOnWriteArrayList is a thread-safe variant of
java.util.ArrayList in which all mutative (nonimmutable) operations
(add,set,andsoon)areimplementedbymakingafreshcopyoftheunderlying
array.
CopyOnWriteArraySet is a java.util.Set implementation that uses
an internal CopyOnWriteArrayList instance for all its operations.
Listing6-3 uses BlockingQueue and ArrayBlockingQueue inanalternative
to Listing 4-27 's producer-consumer application ( PC ).
Listing 6-3. The blocking queue equivalent of Listing 4-27 ' s PC application
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
class PC
{
public static void main(String[] args)
{
final BlockingQueue<Character> bq;
bq = new ArrayBlockingQueue<Character>(26);
final
ExecutorService
executor
=
Execut-
ors.newFixedThreadPool(2);
Runnable producer;
producer = new Runnable()
{
 
Search WWH ::




Custom Search