MemoizingSupplier is keeping the delegate forever.
NonSerializableMemoizingSupplier is releasing the delegate (delegate =
null) when the value is captured because it's not needed anymore.

That's why one is final and the other volatile.

Why they are not behaving the same way is a good question.

On Thu, 27 Aug 2020 at 07:18, SuperNunrg <[email protected]> wrote:

>
> Thank you all for answers. Let me ask one more question here.
> Guava has a lot of useful classes such as
>
> https://github.com/google/guava/blob/master/guava/src/com/google/common/base/Suppliers.java
> there are two classes MemoizingSupplier and
> NonSerializableMemoizingSupplier
> the first one has delegate marked as final and second as volotile. Why is
> that? could NonSerializableMemoizingSupplier has its delegate marked as
> final?
> has it something to do with GC?
>
> --
> You received this message because you are subscribed to the Google Groups
> "mechanical-sympathy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/mechanical-sympathy/69a4dd6c-8f15-47b7-936c-17761b481df6o%40googlegroups.com
> <https://groups.google.com/d/msgid/mechanical-sympathy/69a4dd6c-8f15-47b7-936c-17761b481df6o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/mechanical-sympathy/CADZL2%3DtjuFFn9pPMBApmG8dVZ5CNNNetEXogZ1H9%2BjyuUU9%2B3w%40mail.gmail.com.

Reply via email to