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 onsynchronizedmethods, greatly increasing the number of threads that can safely use them concurrently.ConcurrentHashMapimplements theConcurrentMapinterface, which adds important atomic methods to the basejava.util.Mapinterface.
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.concurrentprovides a robust framework for asynchronous execution of tasks defined by the existingjava.lang.Runnableinterface or the newCallableinterface. TheExecutor,ExecutorService, andScheduledExecutorServiceinterfaces define methods for executing (or scheduling for future execution)RunnableandCallabletasks. TheFutureinterface represents the future result of the asynchronous execution of a task.ThreadPoolExecutorandScheduledThreadPoolExecutor ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access