[concurrency-interest] dealing with people that questionvisibility problems

Peter Veentjer alarmnummer at gmail.com
Thu Feb 22 03:37:50 EST 2007


Hi David,

>>  As I've written before using caches as a motivation
>> is a bad idea. While this is >>theoretically possible
>> given an abstract caching mechanism, in practice
>> cache coherency on modern SMPs won't allow the
>> above to happen.

True. But I needed an example. If you know a better
one, please tell me.

>> Howver, going to the extreme of making every
>> field either final or volatile is pointless. If a field
>> has visibility issues because it isn't volatile,
>>  there's a good chance that it also has atomicity
>>  issues that volatile can't fix.

I agree. In most cases object are not shared
between threads, or are 'really' immutable.
But for those object that are being shared
and are mutable, I suggest doing one of
2 things:
1) make the fields volatile
2) depend on save handoff

In a lot of producer/consumer problems
I rely on number 2 because only a single
thread 'owns' the object at any given moment.

Thank you for your feedback.


More information about the Concurrency-interest mailing list