org.jclarion.clarion.AbstractThreaded Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clarion-runtime Show documentation
Show all versions of clarion-runtime Show documentation
JClarion runtime environment
The newest version!
package org.jclarion.clarion;
import org.jclarion.clarion.primative.AbstractStateFactory;
import org.jclarion.clarion.primative.AbstractStateGetter;
import org.jclarion.clarion.primative.GlobalStateGetter;
import org.jclarion.clarion.primative.ThreadStateGetter;
public abstract class AbstractThreaded implements Threaded
{
public static class State
{
public State() { }
}
private static class StateFactory extends AbstractStateFactory
{
@Override
public State cloneState(State base) {
return new State();
}
@Override
public State createState() {
return new State();
}
}
private static StateFactory factory=new StateFactory();
private AbstractStateGetter state=new GlobalStateGetter(factory);
public Object getThread()
{
initThread();
return this;
}
@Override
public void initThread() {
if (!state.isThreaded()) {
state=new ThreadStateGetter(factory,state);
state.get();
}
}
protected void lock(AbstractThreaded base,Thread t)
{
state=base.state.getLockedGetter(t);
}
@Override
public boolean isThreaded() {
return state.isThreaded();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy