Changes to concurrency tools in Java 8 and Java 9 __java

Source: Internet
Author: User
Tags java se

Click " programmer Big Coffee " above, select "Public number"

Critical moment, first time delivery.


Some changes have been made to the concurrent packages in Java 8 and Java 9, and the changes are summarized in this article.


changes in Concurrent package in Java 8


new classes and interfaces in Java.util.concurrent


Two new interfaces and 4 new classes were added:


Interface Completablefuture.asynchronouscompletiontask

Interface Completionstage

Class Completablefuture

Class Concurrenthashmap.keysetview

Class Countedcompleter

Class Completionexception


a new method of Java.util.concurrent.ConcurrentHashMap


The collection framework has been revised in Java 8 to add a number of aggregation methods based on stream and lambda expressions. So Concurrenthashmap also introduced 30 new methods, including a variety of foreach methods (foreach, Foreachkey, Foreachvalue, and Foreachentry), search methods (searching, sea Rchkeys, Searchvalues, and searchentries) and reduction methods (reduce, reducetodouble, Reducetolong, etc.).


Some other methods have been added, such as Mappingcount and Newkeyset. and the current version of the Concurrenthashmap is more suitable for cache, because it increases the check method when the key value does not exist.


new classes in the Java.util.concurrent.atomic


In order to compute count and sum concurrently, new Doubleaccumulator, Doubleadder, Longaccumulator, Longadder classes are introduced, providing a higher throughput rate than atomic.


a new method of Java.util.concurrent.ForkJoinPool


Static Commonpool () is added to provide a universal pool for forkjointask.


Two methods Getcommonpoolparallelism () and Commonpool () provide different configurations.


New Class Java.util.concurrent.locks.StampedLock


The new class Stampedlock provides three modes (write, read, and optimistic) to improve performance.


changes in Concurrent package in Java 9


The main is Jep 266:more concurrency Updates, including publish-subscribe, completablefuture interface strengthening and so on.


Support for reactive STREAMS Publish-subscribe Framework, four interfaces Processor, Publisher, subscriber, Subscription, container class Java.util.concurrent.f Low, Java.util.concurrent.SubmissionPublisher

Completablefuture class strengthens, supports delays, timeout, subclassing, and other methods

Tuning and modifying Javadoc


reference Documentation


Concurrency Utilities Enhancements in Java SE 8

Https://docs.oracle.com/javase/8/docs/technotes/guides/concurrency/changes8.html

Java 9′s Other new enhancements, part 6:concurrency

Https://www.javaworld.com/article/3198904/learn-java/java-9s-other-new-enhancements-part-6-concurrency.html

The Essential Java 9 Feature you Probably Never Heard of

https://blog.takipi.com/the-essential-java-9-feature-you-probably-never-heard-of/

Java 9′s Other New enhancements

Https://www.infoworld.com/article/3169289/java/java-9s-other-new-enhancements-part-2.html

Jep 266:more concurrency Updates

http://openjdk.java.net/jeps/266

Java 9 Series:concurrency Updates

https://www.voxxed.com/2016/10/java-9-series-concurrency-updates/


Some changes have been made to the concurrent packages in Java 8 and Java 9, and the changes are summarized in this article.


Source: Bird's Nest

colobu.com/2018/03/12/concurrency-utilities-enhancements-in-java-8-java-9/

Programmers to organize the release, reprint please contact the author to obtain authorization

"Click to become the Great God of Android"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.