package nl.tudelft.simulation.dsol.interpreter;
import nl.tudelft.simulation.logger.Logger;
/**
* A InterpretationThread
*
* (c) copyright 2002-2014 Delft University of Technology.
* BSD-style license. See DSOL License.
* @author Peter Jacobs
* @author Alexander Verbraeck
* @since 1.5
*/
public final class InterpretationThread extends Thread
{
/** the target of this interpretation. */
private Runnable target = null;
/**
* constructs a new InterpretationThread.
* @param target the target.
*/
public InterpretationThread(final Runnable target)
{
super();
this.target = target;
}
/**
* constructs a new InterpretationThread.
* @param target the target.
* @param name the name of the thread
*/
public InterpretationThread(final Runnable target, final String name)
{
super(name);
this.target = target;
}
/**
* constructs a new InterpretationThread.
* @param group the threadGroup
* @param target the target.
*/
public InterpretationThread(final ThreadGroup group, final Runnable target)
{
super(group, target);
this.target = target;
}
/**
* constructs a new InterpretationThread.
* @param group the threadGroup
* @param target the target.
* @param name the name of the thread
*/
public InterpretationThread(final ThreadGroup group, final Runnable target, final String name)
{
super(group, target, name);
this.target = target;
}
/** {@inheritDoc} */
@Override
public void run()
{
try
{
Interpreter.invoke(this.target, this.target.getClass().getDeclaredMethod("run"), null);
}
catch (Exception exception)
{
Logger.warning(this, "run", exception);
}
}
}