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. package java.lang;
  8. /**
  9. * The <code>Runnable</code> interface should be implemented by any
  10. * class whose instances are intended to be executed by a thread. The
  11. * class must define a method of no arguments called <code>run</code>.
  12. * <p>
  13. * This interface is designed to provide a common protocol for objects that
  14. * wish to execute code while they are active. For example,
  15. * <code>Runnable</code> is implemented by class <code>Thread</code>.
  16. * Being active simply means that a thread has been started and has not
  17. * yet been stopped.
  18. * <p>
  19. * In addition, <code>Runnable</code> provides the means for a class to be
  20. * active while not subclassing <code>Thread</code>. A class that implements
  21. * <code>Runnable</code> can run without subclassing <code>Thread</code>
  22. * by instantiating a <code>Thread</code> instance and passing itself in
  23. * as the target. In most cases, the <code>Runnable</code> interface should
  24. * be used if you are only planning to override the <code>run()</code>
  25. * method and no other <code>Thread</code> methods.
  26. * This is important because classes should not be subclassed
  27. * unless the programmer intends on modifying or enhancing the fundamental
  28. * behavior of the class.
  29. *
  30. * @author Arthur van Hoff
  31. * @version 1.24, 12/19/03
  32. * @see java.lang.Thread
  33. * @since JDK1.0
  34. */
  35. public
  36. interface Runnable {
  37. /**
  38. * When an object implementing interface <code>Runnable</code> is used
  39. * to create a thread, starting the thread causes the object's
  40. * <code>run</code> method to be called in that separately executing
  41. * thread.
  42. * <p>
  43. * The general contract of the method <code>run</code> is that it may
  44. * take any action whatsoever.
  45. *
  46. * @see java.lang.Thread#run()
  47. */
  48. public abstract void run();
  49. }