nyla.solutions.global.patterns.workthread.StartState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nyla.solutions.global Show documentation
Show all versions of nyla.solutions.global Show documentation
Nyla Solutions Global Java API provides support for basic application
utilities (application configuration, data encryption, debugger and text
processing).
The newest version!
package nyla.solutions.global.patterns.workthread;
import nyla.solutions.global.util.Debugger;
/**
*
*
* StartState starts a worker's thread if it is not alive
*
* @author Gregory Green
* @version 1.0
*/
public class StartState implements WorkState
{
/**
*
* @see java.lang.Runnable#run()
*/
public void advise(SupervisedWorker worker)
{
if(worker == null)
return;
Debugger.println(this, "Advising the worker "+worker.getName());
Thread workerThread = worker.getThread();
if(!workerThread.isAlive())
{
workerThread.start();
}
}// --------------------------------------------
/**
* @return the name
*/
public String getName()
{
return name;
}// --------------------------------------------
/**
*
* @see java.lang.Object#toString()
*/
public String toString()
{
return name;
}// --------------------------------------------
private String name = this.getClass().getName();
}