emul/src/main/java/java/lang/Runnable.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 23 Jan 2013 12:01:45 +0100
branchjdk7-b147
changeset 539 1831d3ddc7f0
permissions -rw-r--r--
How could I miss Runnable?
jaroslav@539
     1
/*
jaroslav@539
     2
 * Copyright (c) 1994, 2005, Oracle and/or its affiliates. All rights reserved.
jaroslav@539
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@539
     4
 *
jaroslav@539
     5
 * This code is free software; you can redistribute it and/or modify it
jaroslav@539
     6
 * under the terms of the GNU General Public License version 2 only, as
jaroslav@539
     7
 * published by the Free Software Foundation.  Oracle designates this
jaroslav@539
     8
 * particular file as subject to the "Classpath" exception as provided
jaroslav@539
     9
 * by Oracle in the LICENSE file that accompanied this code.
jaroslav@539
    10
 *
jaroslav@539
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@539
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@539
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
jaroslav@539
    14
 * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@539
    15
 * accompanied this code).
jaroslav@539
    16
 *
jaroslav@539
    17
 * You should have received a copy of the GNU General Public License version
jaroslav@539
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@539
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@539
    20
 *
jaroslav@539
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@539
    22
 * or visit www.oracle.com if you need additional information or have any
jaroslav@539
    23
 * questions.
jaroslav@539
    24
 */
jaroslav@539
    25
jaroslav@539
    26
package java.lang;
jaroslav@539
    27
jaroslav@539
    28
/**
jaroslav@539
    29
 * The <code>Runnable</code> interface should be implemented by any
jaroslav@539
    30
 * class whose instances are intended to be executed by a thread. The
jaroslav@539
    31
 * class must define a method of no arguments called <code>run</code>.
jaroslav@539
    32
 * <p>
jaroslav@539
    33
 * This interface is designed to provide a common protocol for objects that
jaroslav@539
    34
 * wish to execute code while they are active. For example,
jaroslav@539
    35
 * <code>Runnable</code> is implemented by class <code>Thread</code>.
jaroslav@539
    36
 * Being active simply means that a thread has been started and has not
jaroslav@539
    37
 * yet been stopped.
jaroslav@539
    38
 * <p>
jaroslav@539
    39
 * In addition, <code>Runnable</code> provides the means for a class to be
jaroslav@539
    40
 * active while not subclassing <code>Thread</code>. A class that implements
jaroslav@539
    41
 * <code>Runnable</code> can run without subclassing <code>Thread</code>
jaroslav@539
    42
 * by instantiating a <code>Thread</code> instance and passing itself in
jaroslav@539
    43
 * as the target.  In most cases, the <code>Runnable</code> interface should
jaroslav@539
    44
 * be used if you are only planning to override the <code>run()</code>
jaroslav@539
    45
 * method and no other <code>Thread</code> methods.
jaroslav@539
    46
 * This is important because classes should not be subclassed
jaroslav@539
    47
 * unless the programmer intends on modifying or enhancing the fundamental
jaroslav@539
    48
 * behavior of the class.
jaroslav@539
    49
 *
jaroslav@539
    50
 * @author  Arthur van Hoff
jaroslav@539
    51
 * @see     java.lang.Thread
jaroslav@539
    52
 * @see     java.util.concurrent.Callable
jaroslav@539
    53
 * @since   JDK1.0
jaroslav@539
    54
 */
jaroslav@539
    55
public
jaroslav@539
    56
interface Runnable {
jaroslav@539
    57
    /**
jaroslav@539
    58
     * When an object implementing interface <code>Runnable</code> is used
jaroslav@539
    59
     * to create a thread, starting the thread causes the object's
jaroslav@539
    60
     * <code>run</code> method to be called in that separately executing
jaroslav@539
    61
     * thread.
jaroslav@539
    62
     * <p>
jaroslav@539
    63
     * The general contract of the method <code>run</code> is that it may
jaroslav@539
    64
     * take any action whatsoever.
jaroslav@539
    65
     *
jaroslav@539
    66
     * @see     java.lang.Thread#run()
jaroslav@539
    67
     */
jaroslav@539
    68
    public abstract void run();
jaroslav@539
    69
}