Their method ensures that even if other code still holds references to particular nodes, the other nodes will be GC'ed.
Otherwise, even a single external reference to one of the nodes would prevent the entire chain from being collected.
Also, other operations in the list might be going on simultaneously (e.g. views through subList()
or Collections.unmodifiableList()
, iterators), and this ensures that those things perceive the list as "empty" immediately.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…