美文网首页
Java Object类

Java Object类

作者: 沐兮_d64c | 来源:发表于2018-04-01 03:59 被阅读0次

Object Structure

image.png

1,线程同步方法

1)notify()方法

  • 唤醒在当前对象监视器上等待的单个线程。Wakes up a single thread that is waiting on this object's monitor.
  • 必须是对象监听器的拥有者线程才能执行notify方法。This method should only be called by a thread that is the owner of this object's monitor.
  • 成为对象监听器拥有者的3中方法。A thread becomes the owner of the object's monitor in one of three ways
    执行该对象的synchronized实例方法By executing a synchronized instance method of that object.
    执行该对象的synchronized语句By executing the body of a synchronized statement that synchronizes on the object.
    执行类的synchronized静态方法executing a synchronized static method of that class.
    2)notifyAll()方法
    唤醒在当前对象监听器上等待的所有线程。Wakes up all threads that are waiting on this object's monitor.
    必须是对象监听器的拥有者线程才能执行notify方法。This method should only be called by a thread that is the owner of this object's monitor.
    3)wait方法
    导致当前线程等待,直到其他线程调用notify或者notifyAll方法。Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.

2,其他方法

1)hashCode方法Returns a hash code value for the object.
对hash表结构提供支持。例如HashMap、hashTable等。This method is supported for the benefit of hash tables such as those provided by HashMap.
2)toString方法
默认return getClass().getName() + "@" + Integer.toHexString(hashCode());
3)equals方法
默认比较两个引用是否相同。return (this == obj);
4)public final native Class<?> getClass();方法。
获取对象的类类型。

3,垃圾回收

1)finalize方法
GC在回收对象之前调用该方法。Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

相关文章

  • 06 Java常用类

    java.lang.Object类 所有Java类的最终祖先,编译系统默认继承Object类,Object类包含了...

  • day12界面版抢红包、Object类、常用API

    界面版抢红包 Object类 java.lang.Object 类是Java语言的根类,即所有类父类。Object...

  • Java-浅析Object类

    Java-浅析Object类 ++2016.7.19++byside @Java-浅析Object类 ======...

  • Java基础再回顾-初类Object篇

    关于Object Object类是Java中其他所有类的祖先,没有Object类Java面向对象无从谈起。作为其他...

  • java day 16

    Object Object类是类层次结构的根,Java中所有的类从根本上都继承自这个类。Object类是Java中...

  • Object & Math & System的API

    Object & Math& System的API Object类 •Object类是Java中其他所有类的基类;...

  • Java面向对象

    Java 继承 所有Java的类均是由java.lang.Object类继承而来的,所以Object是所有类的祖先...

  • Java常用类

    1. Object类 java.lang.object类是所有类的父类,默认继承Obecjt类。Object类常用...

  • Java之Object

    Object类是java类的根基类 Object类中的toString()方法: 1、SUN在object类中设计...

  • Java基础语法_Day17

    一、Object类 & System类 Object类 概述Object类是Java语言中的根类,即所有类的父类。...

网友评论

      本文标题:Java Object类

      本文链接:https://www.haomeiwen.com/subject/lmqocftx.html