EXECUTION
Implementing Finalization
12.6.1
The life cycle of an object obeys the following transition diagram, where we
abbreviate finalizer reachable as f reachable :
object
A
created
reachable
reachable
reachable
J
unfinalized
finalizable
finalized
B
C
K
D
L
M
N
f reachable
f reachable
f reachable
G
E
F
unfinalized
finalizable
finalized
H
unreachable
unreachable
unfinalized
finalized
I
O
storage
finalize
not overridden
reclaimed
When an object is first created (
A
), it is reachable and unfinalized.
As references to an object are discarded during program execution, an object
that was reachable may become finalizer reachable (
B
,
C
,
D
) or unreachable (
E
,
F
).
(Note that a finalizer reachable object never becomes unreachable directly; it
becomes reachable when the finalizer from which it can be reached is invoked, as
explained below.)
If the Java Virtual Machine detects that an unfinalized object has become
finalizer reachable or unreachable, it may label the object finalizable (
G
,
H
); more
over, if the object was unreachable, it becomes finalizer reachable (
H
).
If the Java Virtual Machine detects that a finalized object has become
unreachable, it may reclaim the storage occupied by the object because the object
will never again become reachable (
I
).
At any time, a Java Virtual Machine may take any finalizable object, label it
finalized, and then invoke its
finalize
method in some thread. This causes the
object to become finalized and reachable (
J
,
K
), and it also may cause other objects
that were finalizer reachable to become reachable again (
L
,
M
,
N
).
233
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved