Synchronized const methods
"Jérôme M. Berger"
jeberger at free.fr
Sat Jun 12 00:28:58 PDT 2010
Daniel Keep wrote:
> immutable means "no one can modify this."
>
> const means "someone might be able to modify this, but not you can't."
So?
Basically, what the OP said, is that we need readers-writer locks
[1]. A const synchronized method would use the read lock (and
therefore several threads can access the same object through *const*
synchronized methods simultaneously), but a non const synchronized
method would use the read-write lock (which would prevent anyone
else from accessing the same object through a synchronized method,
be it const or not).
Jerome
[1] http://en.wikipedia.org/wiki/Readers-writer_lock
--
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100612/0cbba97b/attachment.pgp>
More information about the Digitalmars-d-learn
mailing list