Welcome to Oracle Communities
Register and Participate in Oracle's online communities. Learn from thousands of experts, get answers to your questions and share knowledge with peers.
Choose a layout and drag widgets onto your Overview Page to customize it. Widgets placed on the page below can be configured by selecting the symbol.
Any text you want.
Thread Safety with Phaser
CountDownLatch is easy to understand, but hard to use. Phaser is the opposite. Hard to understand, easy to use. With CountDownLatch, we only have two methods: await() and countDown(). Phaser endows us with: register(), arrive(), arriveAndAwaitAdvance(), arriveAndDeregister(), awaitAdvance(), awaitAdvanceInterruptibly() and a bunch of management methods. In this talk, we spend an hour explaining the intricacies of Phaser. It is for Java programmers who are already familiar with thread safety programming. We also show a demo that compares the performance of coordinated tasks using wait/notify, CountDownLatch, CyclicBarrier, volatile spin loops, and Phaser. In the end, Phaser performs the best with the most simple code. We then go into tiered Phasers, an approach to further reduce thread contention. We end with a look at ManagedBlocker and how this allows Phaser to work with parallel streams.
Heinz Kabutz is the author of The Java Specialists’ Newsletter (https://www.javaspecialists.eu), a publication enjoyed by tens of thousands of Java experts in over 149 countries. His book “Dynamic Proxies (in German)” was #1 Bestseller on Amazon.de in Fachbücher für Informatik for about five minutes until Amazon fixed their algorithm. Thanks to a supportive mother, he has now sold 5 copies.
Heinz’s Java Specialists’ newsletter is filled with amusing anecdotes of life on the Island of Crete. He is a popular speaker at all the best Java conferences around the world, and also at some of the worst. He teaches Java courses in classrooms around the world, where his prime objective is to make absolutely sure that none of his students fall asleep. He is not always successful.
* US$300 free credits available in select countries and valid for up to 30 days. You can run a maximum of 8 instances across all available services and up to 5 TB of storage during the promotional period. Oracle Cloud credits are consumed at discounted rates during the 30-day promotional period. The capacity limits listed under each service are only estimates and reflect the maximum capacity you can get if you consume your entire credits on one service during the promotional period. The maximum capacity per service you get can be less if you consume multiple services. The list of services and capacity estimates are subject to change. Your credit balance is available to you on the Oracle My Services dashboard.