Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Key to locking success: Java Memory Model

 
Chris Be
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A hint to anyone working on the locking: the key to success is the "Java Memory Model".

With your code level instructions, or as in my case at times the lack of such, your compiler will receive instructions on on how your specified code execution order may be reorderable when it actually runs. And the compiler/jvm's interpretation will vary between java versions!

So, your code may actually execute in another order to what you think it is according to your written code.

JSR-133 and JSR-166 with related articles gave me some AHA effects on my unexpectedly poor locking score.

I would dare to say if you are using, but not fully across the Java Memory Model implication of synchronize AND volatile AND final (or equivalent util.concurrent abstractions), your locking may likely be (like mine) in elements inferior/incomplete. This is not to say it doesn't work on your machine, but will it on a dual or quad core, or in exceptional conditions (e.g. exttremely high load), or with another java version?

If you are not across java concurrency as above, listen to this podcast for an instant AHA effect .

Have fun understanding Java better than many others.

[ February 19, 2008: Message edited by: Chris Be ]
[ February 19, 2008: Message edited by: Chris Be ]
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, thanks Chris, as always your post are really informative (last one being the anti-patterns for Exception).

You really opened my eyes on a beast. I didn't even begin to suspect such thing.

Thanks
Alex
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic