src/java.base/share/classes/java/lang/Runnable.java
changeset 58288 48e480e56aad
parent 47216 71c04702a3d5
equal deleted inserted replaced
58287:a7f16447085e 58288:48e480e56aad
     1 /*
     1 /*
     2  * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    24  */
    24  */
    25 
    25 
    26 package java.lang;
    26 package java.lang;
    27 
    27 
    28 /**
    28 /**
    29  * The <code>Runnable</code> interface should be implemented by any
    29  * The {@code Runnable} interface should be implemented by any
    30  * class whose instances are intended to be executed by a thread. The
    30  * class whose instances are intended to be executed by a thread. The
    31  * class must define a method of no arguments called <code>run</code>.
    31  * class must define a method of no arguments called {@code run}.
    32  * <p>
    32  * <p>
    33  * This interface is designed to provide a common protocol for objects that
    33  * This interface is designed to provide a common protocol for objects that
    34  * wish to execute code while they are active. For example,
    34  * wish to execute code while they are active. For example,
    35  * <code>Runnable</code> is implemented by class <code>Thread</code>.
    35  * {@code Runnable} is implemented by class {@code Thread}.
    36  * Being active simply means that a thread has been started and has not
    36  * Being active simply means that a thread has been started and has not
    37  * yet been stopped.
    37  * yet been stopped.
    38  * <p>
    38  * <p>
    39  * In addition, <code>Runnable</code> provides the means for a class to be
    39  * In addition, {@code Runnable} provides the means for a class to be
    40  * active while not subclassing <code>Thread</code>. A class that implements
    40  * active while not subclassing {@code Thread}. A class that implements
    41  * <code>Runnable</code> can run without subclassing <code>Thread</code>
    41  * {@code Runnable} can run without subclassing {@code Thread}
    42  * by instantiating a <code>Thread</code> instance and passing itself in
    42  * by instantiating a {@code Thread} instance and passing itself in
    43  * as the target.  In most cases, the <code>Runnable</code> interface should
    43  * as the target.  In most cases, the {@code Runnable} interface should
    44  * be used if you are only planning to override the <code>run()</code>
    44  * be used if you are only planning to override the {@code run()}
    45  * method and no other <code>Thread</code> methods.
    45  * method and no other {@code Thread} methods.
    46  * This is important because classes should not be subclassed
    46  * This is important because classes should not be subclassed
    47  * unless the programmer intends on modifying or enhancing the fundamental
    47  * unless the programmer intends on modifying or enhancing the fundamental
    48  * behavior of the class.
    48  * behavior of the class.
    49  *
    49  *
    50  * @author  Arthur van Hoff
    50  * @author  Arthur van Hoff
    53  * @since   1.0
    53  * @since   1.0
    54  */
    54  */
    55 @FunctionalInterface
    55 @FunctionalInterface
    56 public interface Runnable {
    56 public interface Runnable {
    57     /**
    57     /**
    58      * When an object implementing interface <code>Runnable</code> is used
    58      * When an object implementing interface {@code Runnable} is used
    59      * to create a thread, starting the thread causes the object's
    59      * to create a thread, starting the thread causes the object's
    60      * <code>run</code> method to be called in that separately executing
    60      * {@code run} method to be called in that separately executing
    61      * thread.
    61      * thread.
    62      * <p>
    62      * <p>
    63      * The general contract of the method <code>run</code> is that it may
    63      * The general contract of the method {@code run} is that it may
    64      * take any action whatsoever.
    64      * take any action whatsoever.
    65      *
    65      *
    66      * @see     java.lang.Thread#run()
    66      * @see     java.lang.Thread#run()
    67      */
    67      */
    68     public abstract void run();
    68     public abstract void run();