v****s 发帖数: 1112 | 1 From Java API doc:
finalize
protected void finalize()
throws Throwable
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object. A subclass
overrides the finalize method to dispose of system resources or to perform
other cleanup.
问题是,这个gc是以何种形式在runtime中出现的?为何这个finalize()要定义成
protected而不是
private? 具体给讲讲? |
X****r 发帖数: 3557 | 2 If you have resource to be disposed of, make an explicit method to
do so. Don't use finalizer. There is no guarantee that when
finalizer is to be called, or even be called at all.
perform
【在 v****s 的大作中提到】![](/moin_static193/solenoid/img/up.png) : From Java API doc: : finalize : protected void finalize() : throws Throwable : Called by the garbage collector on an object when garbage collection : determines that there are no more references to the object. A subclass : overrides the finalize method to dispose of system resources or to perform : other cleanup. : 问题是,这个gc是以何种形式在runtime中出现的?为何这个finalize()要定义成 : protected而不是
|
g*****g 发帖数: 34805 | 3 If you are an average developer, chances are you never ever
need to call finalize
【在 v****s 的大作中提到】![](/moin_static193/solenoid/img/up.png) : From Java API doc: : finalize : protected void finalize() : throws Throwable : Called by the garbage collector on an object when garbage collection : determines that there are no more references to the object. A subclass : overrides the finalize method to dispose of system resources or to perform : other cleanup. : 问题是,这个gc是以何种形式在runtime中出现的?为何这个finalize()要定义成 : protected而不是
|
v****s 发帖数: 1112 | 4 sorry, im asking how JVM is gonna call "object.finalize()", not by my code.
since my java code is not gonna take care of gc.
【在 g*****g 的大作中提到】![](/moin_static193/solenoid/img/up.png) : If you are an average developer, chances are you never ever : need to call finalize
|