[concurrency-interest] @Contended (JEP-142)

Jeff Hain jeffhain at rocketmail.com
Thu Nov 29 17:42:39 EST 2012


>IMHO, sun.misc.Contended is the right place for this one,
>as it will
hopefully discourage people from using it,
>unless they really know what
they are doing.


It will also discourage people from using it, even though
they would know what they are doing, if they want to make
efficient AND portable libraries.
To remain portable I'll stick to hand-made padding until
@Contented or equivalent makes it to non-JVMese Java.
That said, I understand that it might not be a good idea
to promote such a low-level feature into the language
(maybe some day could we have the JVM figure out and create
padding dynamically?).




>Next you find programmers making all their fields "Contended",
>because they read on some blog that it makes things
faster.
>Then instead of your object using only 32 bytes, it gets
>bloated to 512 bytes.


Programmers already have access to much more dangerous features

such as System.exit(...), while loops, new (!!!), etc.
If people have trouble understanding that it causes memory padding,
maybe it could be renamed into @CacheLinePadded.



-Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20121129/5e5be465/attachment.html>


More information about the Concurrency-interest mailing list