There's more...

You have four different access types to a variable with a variable handle:

  • Read mode: This is used to get read mode access to a variable. You can use the following methods:
    • get(): Read the value of the variable as if it was declared non-volatile
    • getVolatile(): Read the value of the variable as if it was declared volatile
    • getAcquire(): Read the value of the variable and guarantee that the following instructions that modify or access this variable are not reordered before the instructions for optimization purposes
    • getOpaque(): Read the value of variable and guarantee that the instructions of the current thread are not reordered; no guarantee is provided for other threads
  • Write mode: This is used to get write access mode ...

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.