The return value of putIfAbsent is existing if it already exists or null if it did not exist, and we put a new one.
f = cache.putIfAbsent(arg, ft); if (f == null) { f = ft; ft.run(); }
So, if ( f == null ) means "Have we put ft in the cache?". Obviously, if we did put it in the cache, we now need to set f to the one in the cache, i.e. ft .
If we did not put ft in the cache, then f already the one in the cache, because this is the value returned by putIfAbsent .
source share