Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > Think in java 答案_Chapter 4_Exercise 12
【标  题】:Think in java 答案_Chapter 4_Exercise 12
【关键字】:Think,in,java,_Chapter,4_Exercise
【来  源】:http://blog.csdn.net/heimaoxiaozi/archive/2007/01/23/1490987.aspx

Think in java 答案_Chapter 4_Exercise 12

Your Ad Here

阅前声明: http://blog.csdn.net/heimaoxiaozi/archive/2007/01/19/1487884.aspx

/****************** Exercise 12 *****************
* Modify Exercise 11 so that your finalize()
* will always be called.
***********************************************/

public class E12_FinalizeAlwaysCalled {
  protected void finalize() {
    System.out.println("Finalize called");
  }
  public static void main(String args[]) {
    new E12_FinalizeAlwaysCalled();
    System.gc();
  }
}

//+M java E12_FinalizeAlwaysCalled

**Calling System.gc( ) will probably cause your finalizer to be called. I say “probably” because the behavior of finalize has been uncertain from one version of the JDK to another. In addition, calling System.gc( ) is just a request, and it doesn’t guarantee that the garbage collector will actually be run.

**Another solution that was put into one version of the JDK, and then deprecated in the next version (just to assure you that they know what they’re doing there at JavaSoft) is to call System.runFinalizersOnExit(). Since this is deprecated, you can’t really use it anymore. Basically, there’s no way to ensure that finalize( ) will be called.


 

Think in java 答案_Chapter 4_Exercise 13:【上一篇】
经典的spring入门:【下一篇】
【相关文章】
  • Think in java 答案_Chapter 4_Exercise 13
  • Think in java 答案_Chapter 4_Exercise 14
  • Think in java 答案_Chapter 4_Exercise 15
  • Think in java 答案_Chapter 4_Exercise 16
  • Think in java 答案_Chapter 4_Exercise 17
  • Think in java 答案_Chapter 4_Exercise 18
  • Think in java 答案_Chapter 4_Exercise 19
  • Think in java 答案_Chapter 4_Exercise 20
  • Think in java 答案_Chapter 4_Exercise 21
  • Think in java 答案_Chapter 4_Exercise 22
  • 【随机文章】
  • 通用数据库排序代码
  • solaris raid 制作大集合
  • MySQL图形化操作详解
  • 当对项目强名时自动构建失败(TeamFoudationServer试用笔记)
  • 用主场中的按钮控制所有MC的停止与播放
  • Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK
  • RHEL 4 性能优化
  • 学了这么久的编程,想写点东西了!!!
  • 烧纸效果
  • 我的笔记本驱动
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.