Object class learning

Method returns the class object getClasss static synchronized method is locked

clone method ran CloneNotSupportedException

x.clone() != x

x.clone().getClass() == x.getClass()

x.clone.equals(x)

The default implementation Cloneable interface array when the internal array clone returned an empty

notify wake up threads, competition with other threads

wait the thread sleep, wake up 4 ways:

1, other thread calls notify, just wake up.

2, other thread calls notifyAll

3, other threads interrupt thread

4, wait time has come

finalize() throws Throwable

When the garbage collector determines that there is no reference to the object, the garbage collector calls the object on the object.

finalize a method of Object subclasses can override this method to do some cleanup release system resources or data.

Can () so that the object is referenced in the finalize again, to avoid being recovered GC; the most common purpose is to do cleanup

This does not guarantee that finalize () must be executed when the thread is not guaranteed to be called finalize holding any user-visible synchronization locks

In finalize which throws an exception will be ignored and the method terminates.

After finalize is called, JVM will once again detects whether the object is alive threads to access, it is not clear. finalize only be called once, covering finalize method of the object to be two GC cycle was only cleared

Guess you like

Origin www.cnblogs.com/waifanneiyuan/p/11542190.html