1. /*
  2. * @(#)Callable.java 1.5 04/01/12
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.util.concurrent;
  8. /**
  9. * A task that returns a result and may throw an exception.
  10. * Implementors define a single method with no arguments called
  11. * <tt>call</tt>.
  12. *
  13. * <p>The <tt>Callable</tt> interface is similar to {@link
  14. * java.lang.Runnable}, in that both are designed for classes whose
  15. * instances are potentially executed by another thread. A
  16. * <tt>Runnable</tt>, however, does not return a result and cannot
  17. * throw a checked exception.
  18. *
  19. * <p> The {@link Executors} class contains utility methods to
  20. * convert from other common forms to <tt>Callable</tt> classes.
  21. *
  22. * @see Executor
  23. * @since 1.5
  24. * @author Doug Lea
  25. * @param <V> the result type of method <tt>call</tt>
  26. */
  27. public interface Callable<V> {
  28. /**
  29. * Computes a result, or throws an exception if unable to do so.
  30. *
  31. * @return computed result
  32. * @throws Exception if unable to compute a result
  33. */
  34. V call() throws Exception;
  35. }