Object

一、源码

public final native Class<?> getClass();

获得运行时的类

public native int hashCode();

获得hash码

public boolean equals(Object obj) {
    return (this == obj);
}

判断对象是否相等

protected native Object clone() throws CloneNotSupportedException;

克隆

public String toString() {
    return getClass().getName() + "@" + Integer.toHexString(hashCode());
}

字符串形式

public final native void notify();
public final native void notifyAll();

唤醒监视该对象的一个或多个线程

public final native void wait(long timeout) throws InterruptedException;
public final void wait(long timeout, int nanos) throws InterruptedException {
    if (timeout < 0) {
        throw new IllegalArgumentException("timeout value is negative");
    }

    if (nanos < 0 || nanos > 999999) {
        throw new IllegalArgumentException(
                            "nanosecond timeout value out of range");
    }

    if (nanos > 0) {
        timeout++;
    }

    wait(timeout);
}
public final void wait() throws InterruptedException {
    wait(0);
}

使当前线程等待

protected void finalize() throws Throwable { }

垃圾回收器调用回收对象

 

posted @ 2020-01-29 23:31  syxsdhy  阅读(124)  评论(0编辑  收藏  举报