O'Reilly logo

Mastering Concurrency Programming with Java 9 - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variable handles

A variable handle is a dynamically typed reference to a variable, static field, or element of array that allows you different access modes to that variable. You can, for example, protect access to that variable in a concurrent application allowing an atomic access to the variable. Until now, you could only obtain this behavior with atomic variables, but now you can use variable handles to obtain the same functionality without using any synchronization mechanisms.

This mechanism is a new feature in Java 9 and is provided by the VarHandle class. You can get the following access methods to a variable handle:

  • Read access mode: This mode allows you to read the value of the variable with different memory ordering rules depending ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required