Object类是所有类的父类
方法解析:
得到Class
public final native Class<?> getClass();
得到Object hashCode
public native int hashCode();
判断hashCode 决定是否equals
public boolean equals(Object obj) {return (this == obj);}
克隆Object,clone方法是native方法,native方法的效率远高于非native方法,因此还是使用clone方法去做对象的拷贝而不是使用new的方法来copy。
protected native Object clone() throws CloneNotSupportedException;
得到Object名称以及hashCode
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}
唤醒在此对象监视器上等待的单个线程 (每个对象都有锁,锁是每个对象的基础)
public final native void notify();
唤醒在此对象监视器上等待的所有线程
public final native void notifyAll();
导致当前的线程等待,直到其他线程调用此对象的notify() 方法或 notifyAll() 方法,或者指定的时间过完。
public final native void wait(long timeout) throws InterruptedException;
导致当前的线程等待,直到其他线程调用此对象的notify( ) 方法或 notifyAll( ) 方法,或者其他线程打断了当前线程,或者指定的时间过完。
public final void wait(long timeout, int nanos) throws InterruptedException {}
译:导致当前的线程等待,直到其他线程调用此对象的notify( ) 方法或 notifyAll( ) 方法
public final void wait() throws InterruptedException { wait(0); }
通知jvm 进行gc()
protected void finalize() throws Throwable { }