java基础类-3-Object

2019-10-01  本文已影响0人  宠辱不惊的咸鱼

概述

常规方法

private static native void registerNatives();

static {
        registerNatives();
}
public final native Class<?> getClass();
public native int hashCode();
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;
synchronized (obj) {
    while (<condition does not hold>;)
        obj.wait(timeout);
    // Perform action appropriate to condition
}

gc相关

protected void finalize() throws Throwable { }
上一篇 下一篇

猜你喜欢

热点阅读