jaroslav@539: /*
jaroslav@539: * Copyright (c) 1994, 2005, Oracle and/or its affiliates. All rights reserved.
jaroslav@539: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@539: *
jaroslav@539: * This code is free software; you can redistribute it and/or modify it
jaroslav@539: * under the terms of the GNU General Public License version 2 only, as
jaroslav@539: * published by the Free Software Foundation. Oracle designates this
jaroslav@539: * particular file as subject to the "Classpath" exception as provided
jaroslav@539: * by Oracle in the LICENSE file that accompanied this code.
jaroslav@539: *
jaroslav@539: * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@539: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@539: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jaroslav@539: * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@539: * accompanied this code).
jaroslav@539: *
jaroslav@539: * You should have received a copy of the GNU General Public License version
jaroslav@539: * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@539: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@539: *
jaroslav@539: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@539: * or visit www.oracle.com if you need additional information or have any
jaroslav@539: * questions.
jaroslav@539: */
jaroslav@539:
jaroslav@539: package java.lang;
jaroslav@539:
jaroslav@539: /**
jaroslav@539: * The Runnable
interface should be implemented by any
jaroslav@539: * class whose instances are intended to be executed by a thread. The
jaroslav@539: * class must define a method of no arguments called run
.
jaroslav@539: *
jaroslav@539: * This interface is designed to provide a common protocol for objects that
jaroslav@539: * wish to execute code while they are active. For example,
jaroslav@539: * Runnable
is implemented by class Thread
.
jaroslav@539: * Being active simply means that a thread has been started and has not
jaroslav@539: * yet been stopped.
jaroslav@539: *
jaroslav@539: * In addition, Runnable
provides the means for a class to be
jaroslav@539: * active while not subclassing Thread
. A class that implements
jaroslav@539: * Runnable
can run without subclassing Thread
jaroslav@539: * by instantiating a Thread
instance and passing itself in
jaroslav@539: * as the target. In most cases, the Runnable
interface should
jaroslav@539: * be used if you are only planning to override the run()
jaroslav@539: * method and no other Thread
methods.
jaroslav@539: * This is important because classes should not be subclassed
jaroslav@539: * unless the programmer intends on modifying or enhancing the fundamental
jaroslav@539: * behavior of the class.
jaroslav@539: *
jaroslav@539: * @author Arthur van Hoff
jaroslav@539: * @see java.lang.Thread
jaroslav@539: * @see java.util.concurrent.Callable
jaroslav@539: * @since JDK1.0
jaroslav@539: */
jaroslav@539: public
jaroslav@539: interface Runnable {
jaroslav@539: /**
jaroslav@539: * When an object implementing interface Runnable
is used
jaroslav@539: * to create a thread, starting the thread causes the object's
jaroslav@539: * run
method to be called in that separately executing
jaroslav@539: * thread.
jaroslav@539: *
jaroslav@539: * The general contract of the method run
is that it may
jaroslav@539: * take any action whatsoever.
jaroslav@539: *
jaroslav@539: * @see java.lang.Thread#run()
jaroslav@539: */
jaroslav@539: public abstract void run();
jaroslav@539: }