KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > Runnable


1 /*
2  * @(#)Runnable.java 1.24 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.lang;
9
10 /**
11  * The <code>Runnable</code> interface should be implemented by any
12  * class whose instances are intended to be executed by a thread. The
13  * class must define a method of no arguments called <code>run</code>.
14  * <p>
15  * This interface is designed to provide a common protocol for objects that
16  * wish to execute code while they are active. For example,
17  * <code>Runnable</code> is implemented by class <code>Thread</code>.
18  * Being active simply means that a thread has been started and has not
19  * yet been stopped.
20  * <p>
21  * In addition, <code>Runnable</code> provides the means for a class to be
22  * active while not subclassing <code>Thread</code>. A class that implements
23  * <code>Runnable</code> can run without subclassing <code>Thread</code>
24  * by instantiating a <code>Thread</code> instance and passing itself in
25  * as the target. In most cases, the <code>Runnable</code> interface should
26  * be used if you are only planning to override the <code>run()</code>
27  * method and no other <code>Thread</code> methods.
28  * This is important because classes should not be subclassed
29  * unless the programmer intends on modifying or enhancing the fundamental
30  * behavior of the class.
31  *
32  * @author Arthur van Hoff
33  * @version 1.24, 12/19/03
34  * @see java.lang.Thread
35  * @since JDK1.0
36  */

37 public
38 interface Runnable {
39     /**
40      * When an object implementing interface <code>Runnable</code> is used
41      * to create a thread, starting the thread causes the object's
42      * <code>run</code> method to be called in that separately executing
43      * thread.
44      * <p>
45      * The general contract of the method <code>run</code> is that it may
46      * take any action whatsoever.
47      *
48      * @see java.lang.Thread#run()
49      */

50     public abstract void run();
51 }
52
Popular Tags