Name
Package java.util.concurrent
Synopsis
This package includes a number of powerful utilities for multithreaded programming. Most of these utilities fall into three main categories:
- Collections
This package extends the Java Collections Framework, adding the threadsafe classes
ConcurrentHashMap
,CopyOnWriteArrayList
,CopyOnWriteArraySet
, andConcurrentLinkedQueue
. These classes achieve threadsafety without relying exclusively onsynchronized
methods, greatly increasing the number of threads that can safely use them concurrently.ConcurrentHashMap
implements theConcurrentMap
interface, which adds important atomic methods to the basejava.util.Map
interface.
In addition to these Map
, List
,
Set
, and Queue
implementations,
this package also defines the BlockingQueue
interface. Blocking queues are important in many concurrent
algorithms, and this package provides a variety of useful
implementations: ArrayBlockingQueue
,
DelayQueue
,
LinkedBlockingQueue
,
PriorityBlockingQueue
, and
SynchronousQueue
.
- Asynchronous Execution with Thread Pools
java.util.concurrent
provides a robust framework for asynchronous execution of tasks defined by the existingjava.lang.Runnable
interface or the newCallable
interface. TheExecutor
,ExecutorService
, andScheduledExecutorService
interfaces define methods for executing (or scheduling for future execution)Runnable
andCallable
tasks. TheFuture
interface represents the future result of the asynchronous execution of a task.ThreadPoolExecutor
andScheduledThreadPoolExecutor ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.