Is there a good introduction to memory barriers?

I am looking for a good online introduction to memory barriers and common errors in Java code:

  • Using synchronized too often or not often enough
  • When to use volatile and final
  • Double check lock
  • and etc.

I would be particularly interested in code that shows the behavior and / or examples of solving common problems (for example, creating a map that can be accessed by several threads and where values ​​are added lazily).

+4
source share
3 answers

You can find this article from Martin Thomson very helpful.

+5
source

I know what you said online, but Java Concurrency In Practice is a java Concurrency guide these days.

+3
source

If you want to know more about this from a CPU point of view (which assembler code is generated and how the JVM can optimize byte code), this article might be interesting: Memory Barriers and JVM Concurrency (InfoQ)

+1
source

Source: https://habr.com/ru/post/1411301/


All Articles