org.jclarion.clarion.test.SimpleExecutor 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.test;
import java.util.LinkedList;
public class SimpleExecutor extends Thread
{
public SimpleExecutor(String name)
{
super(name);
setDaemon(true);
}
private LinkedList tasks=new LinkedList();
public void deploy(Runnable r) {
synchronized(tasks) {
tasks.add(r);
tasks.notifyAll();
}
}
public void run()
{
while (true) {
Runnable next=null;
synchronized(tasks) {
while (tasks.isEmpty()) {
try {
tasks.wait();
} catch (InterruptedException e) {
return;
}
}
next=tasks.removeFirst();
}
try {
next.run();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy