On 02/14/2018 11:49 AM, Peter Levart wrote:
On 02/14/2018 10:58 AM, Peter Levart wrote:
I take back this claim. Of course the the following race is possible:
- Thread1: calls runAllFinalizers and takes a Finalizer from
- Thread2: takee the same Finalizer instance from ReferenceQueue and
- Thread1: calls runFinalizer() with the same instance for the 2nd
... but this could be "fixed" if the taking of next Finalizer from
'unfinalized' list and removing it from the same list was a single
atomic operation. What do you say of the following further
Even that has a flaw. Running the next unfinalized Finalizer from
runAllFinalizers() does not prevent the same Finalizer to be returned
from the ReferenceQueue. So the check must remain in place.
Sorry for this long monologue. I truly rest now.