Maarten Bosteels wrote:
Hello,
Brian Goetz [1] writes:
"You can use volatile variables instead of locks only under a
restricted set of circumstances. Both of the following criteria must
be met for volatile variables to provide the desired thread-safety:
* Writes to the variable do not depend on its current value.
* The variable does not participate in invariants with other variables.
...
However, if you can arrange that the value is only ever written from a
single thread, then you can ignore the first condition.)"
But at line 445 of BaseIoSession.java I see:
idleCountForRead++;
(in a public method called increaseIdleCount so I don't think we can
guarantee that only one thread will ever call it)
So it's pretty obvious to me that volatile IS NOT good enough if you
want a thread-safe solution.
Exactly. Thanks Marteen.
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org