Class RunnableCallable

java.lang.Object
org.apache.hadoop.lib.lang.RunnableCallable
All Implemented Interfaces:
Runnable, Callable<Void>

@Private public class RunnableCallable extends Object implements Callable<Void>, Runnable
Adapter class that allows Runnables and Callables to be treated as the other.
  • Constructor Details

    • RunnableCallable

      public RunnableCallable(Runnable runnable)
      Constructor that takes a runnable.
      Parameters:
      runnable - runnable.
    • RunnableCallable

      public RunnableCallable(Callable<?> callable)
      Constructor that takes a callable.
      Parameters:
      callable - callable.
  • Method Details

    • call

      public Void call() throws Exception
      Invokes the wrapped callable/runnable as a callable.
      Specified by:
      call in interface Callable<Void>
      Returns:
      void
      Throws:
      Exception - thrown by the wrapped callable/runnable invocation.
    • run

      public void run()
      Invokes the wrapped callable/runnable as a runnable.
      Specified by:
      run in interface Runnable
      Throws:
      RuntimeException - thrown by the wrapped callable/runnable invocation.
    • toString

      public String toString()
      Returns the class name of the wrapper callable/runnable.
      Overrides:
      toString in class Object
      Returns:
      the class name of the wrapper callable/runnable.