zoukankan      html  css  js  c++  java
  • Object类源码详解(基于jdk1.8.0_261)

    1. Object 简介

    • Object是所有类的超类,包括Arrays类都实现了Object类的方法;

    2. Object UML

    3. Object 源码

    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(); //通知第一个wait或最后一个wait的线程继续运行
        public final native void notifyAll(); //通知所有wait的线程依次(可能顺序可能逆序)继续运行
        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); //wait(0)主要是为了让线程放锁,让其他线程有机会得到锁 
        }
        protected void finalize() throws Throwable { }
    }
    
    

    4. Object使用示例

    
    
    
  • 相关阅读:
    vue 交互 跨域获取数据
    计算属性computed缓存 与 methods 的思考
    _this 与 this
    python 占位符 %s Format
    odoo 中字段属性对象Field
    安装CentOS7.7图解
    docker的volumes
    Docker常用命令详解
    Ubuntu修改时区和更新时间
    SqlServer创建时间维度
  • 原文地址:https://www.cnblogs.com/ahpucd/p/13326893.html
Copyright © 2011-2022 走看看