org.apache.hadoop.lib.lang
Class RunnableCallable

java.lang.Object
  extended by 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 Runnables and Callables to be treated as the other.


Constructor Summary
RunnableCallable(Callable<?> callable)
          Constructor that takes a callable.
RunnableCallable(Runnable runnable)
          Constructor that takes a runnable.
 
Method Summary
 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 © 2014 Apache Software Foundation. All Rights Reserved.