Your right System.gc () doesn't guarantee a gc but I've observed one everytime I asked ;-). To see if a gc is forced turn on command line gc logging and
you should see the GC (or not).
After a object is Gc'ed and deemed unretained its finializer is added to a queue for running (different
thread) and indeed and can be saved from GC via a PhantomReference which was on the exam when I did it.
If you believe your System.gc is working you should add this after the Sytem.gc (as your program terminates immediately after) ...
.. if your codes point is to observe finalize in action.
Again its not strictly guaranteed but your code is racing the Finalizer thread which is a daemon thread and will die on main thread exit, basically the spec says finalize happens some time after.
Secret life of finalizer
PS checkedOut is written in one thread and read from another on finalize so it should be marked volatile or equivalent.
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5