package java.lang;
public class Object {
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;
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 >= 500000 || (nanos != 0 && timeout == 0)) {
timeout++;
}
wait(timeout);
}
public final void wait() throws InterruptedException {
wait(0);
}
protected void finalize() throws Throwable { }
}
1.Object clone() 创建并返回此对象的一个副本。
异常
CloneNotSupportedException -- 如果对象的类不支持Cloneable接口。子类覆盖clone方法也会抛出此异常,指示一个实例不能被克隆。
2.boolean equals(Object obj) 指示其他某个对象是否与此对象“相等”。
3.Class<?> getClass() 返回此 Object 的运行时类。
4.int hashCode() 返回该对象的哈希码值。
5.void notify() 唤醒单个线程。
异常
IllegalMonitorStateException --如果当前线程不是此对象监视器的拥有者。
6.void notifyAll() 唤醒在此对象监视器上等待的所有线程。
异常
IllegalMonitorStateException --如果当前线程不是此对象监视器的拥有者。
7.String toString() 返回该对象的字符串表示。
8.void wait() 使当前现成进入等待状态。
异常
IllegalMonitorStateException -- 如果当前线程不是对象监视器的拥有者。
InterruptedException -- 如果另一个线程中断了当前线程。当这种异常被抛出当前线程的中断状态被清除。
9.void wait(long timeout) 使当前现成进入等待状态。
timeout 最大等待时间(毫秒)。
异常
IllegalArgumentException --如果超时的值是负的。
IllegalMonitorStateException -- 如果当前线程不是对象监视器的拥有者。
InterruptedException -- 如果另一个线程中断了当前线程。当这种异常被抛出当前线程的中断状态被清除。
10.void wait(long timeout, int nanos) 使当前现成进入等待状态。
timeout 最大等待时间(毫秒)。
nanos 附加时间在毫微秒范围0-999999。
异常
IllegalArgumentException -- 如果超时的值是负的或毫微秒的值不在0-999999范围内。
IllegalMonitorStateException -- 如果当前线程不是对象监视器的拥有者。
InterruptedException -- 如果另一个线程中断了当前线程。当这种异常被抛出当前线程的中断状态被清除。