Overview of Java Concurrent Packages

Concurrent programming is often used, including some extensible lightweight framework

Executors
interfaces: Executor provides an asynchronous multi-threading framework for task submission and execution, including thread pools, asynchronous I/O, and lightweight asynchronous frameworks . ExecutorService provides a more complete asynchronous task execution framework. An ExecutorService manages queues and scheduled tasks, and allows self-controlled shutdown of tasks; ScheduledExecutorService and associated interfaces support delayed task and periodic task execution; Future provides task execution results Returns the function, and provides a way to cancel the task.

Implementation classes: ThreadPoolExecutor and ScheduledThreadPoolExecutor provide adjustable and flexible thread pools. Executors provide factory methods and some frequently used methods for common configurations and types. Other Executors-based classes, including FutureTask, provide some extensible Futures. ExecutorCompletionService assists in handling asynchronous tasks. ForkJoinPool provides the main design for ForkJoinTask and its subclasses that improve throughput for computationally intensive parallel processing.

Queues
ConcurrentLinkedQueue provides efficient thread-safe, non-blocking FIFO queues
LinkedBlockingQueue, ArrayBlockingQueue, SynchronousQueue, PriorityBlockingQueue, and DelayQueue provide these 5 queues, covering common scenarios: producer-consumer, message, parallel processing, and the associated parallel design.
TransferQueue, LinkedTransferQueue provides synchronous transfer methods.
BlockingDeque LinkedBlockingDeque supports FIFO and LIFO operations.

Timing
TimeUnit provides a variety of granularity (including nanoseconds) specific and timeout control business

Synchronizers
Semaphore A typical concurrent programming tool
CountDownLatch is a very simple but very general and practical, for blocking until a certain number of signals, events, Or conditional hold situations
CyclicBarrier is a multi-way synchronization point useful for some styles of parallel programming
Phaser provides a more flexible barrier that can be used to control segmented computations by multiple threads.
  Exchanger allows 2 threads to exchange objects, which is very useful in pipeline

design Memory Consistency Properties happen-before principle



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326620966&siteId=291194637