Home  >  Q&A  >  body text

java直接使用thread 比runnable优势

伊谢尔伦伊谢尔伦2716 days ago415

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 10:37:03

    According to the description of jdk documentation
    The Runnable interface provides an activation method for classes that are not Thread subclasses. By instantiating a Thread instance and using itself as the run target, you can run a class that implements Runnable without creating a subclass of Thread. In most cases, if you only want to override the run method and not other Thread methods, you should use the Runnable interface. Unless you plan to modify or enhance the basic behavior of Thread.
    ====>Repost from Zhihu, waiting for the answer

    thread bigger?

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:37:03

    One of them is inheritance and the other is interface implementation. Java does not support multiple inheritance, so only interface implementation threads are available.

    reply
    0
  • Cancelreply