Book Image

Mastering Java 11 - Second Edition

By : Dr. Edward Lavieri, Mandar Jog
Book Image

Mastering Java 11 - Second Edition

By: Dr. Edward Lavieri, Mandar Jog

Overview of this book

Java 11 is a long-term release and its new features add to the richness of the language. It emphasizes variable-type inference, performance improvements, along with simplified multithreading. The Java platform has a special emphasis on modularity, making this the programming platform of choice for millions of developers. The modern Java platform can be used to build robust software applications, including enterprise-level and mobile applications. Fully updated for Java 11, this book stands to help any Java developer enjoy the richness of the Java programming language. Mastering Java 11 is your one-stop guide to fully understanding recent Java platform updates. It contains detailed explanations of the recent features introduced in Java 9, Java 10, and Java 11 along with obtaining practical guidance on how to apply the new features. As you make your way through the chapters, you'll discover further information on the developments of the Java platform and learn about the changes introduced by the variable handles and Project Coin, along with several enhancements in relation to import statements processing. In the concluding chapters, you'll learn to improve your development productivity, making your applications more efficient. You'll also be able to get to grips with the command-line flags with respect to various utilities and the command-line utility changes featured in the current Java platform. By the end of the book, you'll have obtained an advanced level understanding of the Java platform and its recent changes.
Table of Contents (20 chapters)

Spin-wait hints

With concurrency, we need to ensure that threads waiting to be executed actually get executed. The concept of spin-wait is a process that continually checks for a true condition. The Java platform has an API that permits Java code to issue hints that a spin loop is currently being executed.

While this is not a feature that every Java developer will use, it can be useful for low-level programming. The hint system simply issues hints—indications and performs no other actions. Justifications for adding these hints include the following assumptions:

  • A spin loop's action time can be improved when using a spin hint
  • Use of spin hints will reduce thread-to-thread latency
  • CPU power consumption will be reduced
  • Hardware threads will execute faster

This hint functionality will be contained in a new onSpinWait() method as part of the java.lang.Thread class. Here...