src/share/classes/java/lang/Runnable.java

Print this page
rev 10048 : 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
Reviewed-by:


  33  * This interface is designed to provide a common protocol for objects that
  34  * wish to execute code while they are active. For example,
  35  * <code>Runnable</code> is implemented by class <code>Thread</code>.
  36  * Being active simply means that a thread has been started and has not
  37  * yet been stopped.
  38  * <p>
  39  * In addition, <code>Runnable</code> provides the means for a class to be
  40  * active while not subclassing <code>Thread</code>. A class that implements
  41  * <code>Runnable</code> can run without subclassing <code>Thread</code>
  42  * by instantiating a <code>Thread</code> instance and passing itself in
  43  * as the target.  In most cases, the <code>Runnable</code> interface should
  44  * be used if you are only planning to override the <code>run()</code>
  45  * method and no other <code>Thread</code> methods.
  46  * This is important because classes should not be subclassed
  47  * unless the programmer intends on modifying or enhancing the fundamental
  48  * behavior of the class.
  49  *
  50  * @author  Arthur van Hoff
  51  * @see     java.lang.Thread
  52  * @see     java.util.concurrent.Callable
  53  * @since   JDK1.0
  54  */
  55 @FunctionalInterface
  56 public interface Runnable {
  57     /**
  58      * When an object implementing interface <code>Runnable</code> is used
  59      * to create a thread, starting the thread causes the object's
  60      * <code>run</code> method to be called in that separately executing
  61      * thread.
  62      * <p>
  63      * The general contract of the method <code>run</code> is that it may
  64      * take any action whatsoever.
  65      *
  66      * @see     java.lang.Thread#run()
  67      */
  68     public abstract void run();
  69 }


  33  * This interface is designed to provide a common protocol for objects that
  34  * wish to execute code while they are active. For example,
  35  * <code>Runnable</code> is implemented by class <code>Thread</code>.
  36  * Being active simply means that a thread has been started and has not
  37  * yet been stopped.
  38  * <p>
  39  * In addition, <code>Runnable</code> provides the means for a class to be
  40  * active while not subclassing <code>Thread</code>. A class that implements
  41  * <code>Runnable</code> can run without subclassing <code>Thread</code>
  42  * by instantiating a <code>Thread</code> instance and passing itself in
  43  * as the target.  In most cases, the <code>Runnable</code> interface should
  44  * be used if you are only planning to override the <code>run()</code>
  45  * method and no other <code>Thread</code> methods.
  46  * This is important because classes should not be subclassed
  47  * unless the programmer intends on modifying or enhancing the fundamental
  48  * behavior of the class.
  49  *
  50  * @author  Arthur van Hoff
  51  * @see     java.lang.Thread
  52  * @see     java.util.concurrent.Callable
  53  * @since   1.0
  54  */
  55 @FunctionalInterface
  56 public interface Runnable {
  57     /**
  58      * When an object implementing interface <code>Runnable</code> is used
  59      * to create a thread, starting the thread causes the object's
  60      * <code>run</code> method to be called in that separately executing
  61      * thread.
  62      * <p>
  63      * The general contract of the method <code>run</code> is that it may
  64      * take any action whatsoever.
  65      *
  66      * @see     java.lang.Thread#run()
  67      */
  68     public abstract void run();
  69 }