org.apache.hadoop.lib.lang

## Class RunnableCallable

- java.lang.Object
- - org.apache.hadoop.lib.lang.RunnableCallable

- All Implemented Interfaces:
    Runnable, Callable<Void>

      @InterfaceAudience.Private
      public class RunnableCallable
      extends Object
      implements Callable<Void>, Runnable

  Adapter class that allows `Runnable`s and `Callable`s to be treated as the other.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RunnableCallable(Callable<?> callable)` Constructor that takes a callable.
    `RunnableCallable(Runnable runnable)` Constructor that takes a runnable.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Void` | `call()` Invokes the wrapped callable/runnable as a callable.
    `void` | `run()` Invokes the wrapped callable/runnable as a runnable.
    `String` | `toString()` Returns the class name of the wrapper callable/runnable.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### 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 Detail

    - #### 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.

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.