How does Java Garbage collector handle self-reference?

后端 未结 7 698
庸人自扰
庸人自扰 2020-11-27 19:23

Hopefully a simple question. Take for instance a Circularly-linked list:

class ListContainer
{
  private listContainer next;
  <..>

  public void setN         


        
7条回答
  •  攒了一身酷
    2020-11-27 20:15

    Simply, Yes. :)

    Check out http://www.ibm.com/developerworks/java/library/j-jtp10283/

    All JDKs (from Sun) have a concept of "reach-ability". If the GC cannot "reach" an object, it goes away.

    This isn't any "new" info (your first to respondents are great) but the link is useful, and brevity is something sweet. :)

提交回复
热议问题