🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #12999

����finalize()������

#12999
From: �̵�����
Date: Sat, 10 Jul 2004 05:46
27 lines
1543 bytes
class Book {
  boolean checkedOut = false;
  Book(boolean checkOut) {
    checkedOut = checkOut;
  }
  void checkIn() {
    checkedOut = false;
  }
  public void finalize() {
    if(checkedOut)
      System.out.println("Error: checked out");
  }
}
public class DeathCondition {
  public static void main(String[] args) {
    Book novel = new Book(true);
    novel.checkIn();
    new Book(true);
    System.gc();
  }
}
����thinking in java �е�һ�γ�������д������Error: checked out���������
��   novel.checkIn();
new Book(true);��ȥ�����Ͳ�����ʾ�ˣ�����Ϊʲô����û���Ǹ�reference�������
��ʱ��ʲô���
--
�� ��Դ:���Ұ��Ͽ�վ nkbbs.org��[FROM: 10.22.33.73] 
Technical Details
Message-ID: <4DAkK2$AOI@bbs.nankai.edu.cn>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-out2.kabelfoon.nl!83.128.0.10.MISMATCH!newsfeed.kabelfoon.nl!maily.cic.tsinghua.edu.cn!news2.happynet.org!NanKai

Show Full Headers
Complete Article Headers
X-Google-Thread: f6cb0,49726a21aed3484f,start
X-Google-Attributes: gidf6cb0,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news-out2.kabelfoon.nl!83.128.0.10.MISMATCH!newsfeed.kabelfoon.nl!maily.cic.tsinghua.edu.cn!news2.happynet.org!NanKai
From: shangshan.bbs@bbs.nankai.edu.cn (�̵�����)
Newsgroups: cn.bbs.comp.lang.java
Subject: ����finalize()������
Date: 10 Jul 2004 05:46:09 GMT
Organization: �Ұ��Ͽ�վ
Message-ID: <4DAkK2$AOI@bbs.nankai.edu.cn>
X-Filename: Java/M.1089438146.A