edu.rice.cs.plt.lambda
Class LazyRunnable
java.lang.Object
edu.rice.cs.plt.lambda.LazyRunnable
- All Implemented Interfaces:
- Runnable
public class LazyRunnable
- extends Object
- implements Runnable
A block of code that executes at most once. The first invocation of run()
runs the code;
subsequent invocations are no-ops. (If an exception occurs during evaluation, the nested runnable will be
evaluated again on a subsequent invocation.)
Evaluation is thread-safe: locking guarantees that the nested code will never be run (and terminate
normally) twice. Thus, if two threads invoke run()
for the first time simultaneously, one will
block until the other completes, and then act as a no-op.
- See Also:
LazyThunk
Method Summary |
void |
run()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LazyRunnable
public LazyRunnable(Runnable block)
run
public void run()
- Specified by:
run
in interface Runnable