com.peterphi.std.threading.ParamRunnable Maven / Gradle / Ivy
package com.peterphi.std.threading;
/**
* A class encapsulating the Runnable idea, mixed with Callable - instead of having a return type, this takes an argument to be
* passed to the run
method
*
* @param T
* the parameter type
*/
public abstract class ParamRunnable
{
protected boolean prepared = false;
public Runnable prepare(T param)
{
if (!prepared)
{
prepared = true;
return new ParamRunnableShell(this, param);
}
else
{
throw new IllegalStateException("Cannot prepare() an already-prepared ParamRunnable");
}
}
public abstract void run(T t);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy