In what situations could an empty synchronized block achieve correct threading semantics?

前端 未结 5 1243
离开以前
离开以前 2020-12-14 16:36

I was looking through a Findbugs report on my code base and one of the patterns that was triggered was for an empty synchronzied block (i.e. synchronized

5条回答
  •  太阳男子
    2020-12-14 17:13

    For an in depth look into Java's memory model, have a look at this video from Google's 'Advanced topics in programming languages' series: http://www.youtube.com/watch?v=1FX4zco0ziY

    It gives a really nice overview of what the compiler can (often in theory, but sometimes in practice) do to your code. Essential stuff for any serious Java programmer!

提交回复
热议问题