org.sdmlib.models.taskflows.SDMThread Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SDMLib Show documentation
Show all versions of SDMLib Show documentation
SDMLib is a light weight modeling library. SDMLib intentionally comes without any tool or editor.
package org.sdmlib.models.taskflows;
import java.util.concurrent.LinkedBlockingQueue;
public class SDMThread extends Thread
{
private LinkedBlockingQueue taskQueue = new LinkedBlockingQueue();
public SDMThread(String name)
{
super(name);
}
@Override
public void run()
{
while (true)
{
try
{
Runnable task = taskQueue.take();
task.run();
}
catch (Exception e)
{
// no problem here
System.err.println("task did not succeed: ");
e.printStackTrace();
}
}
}
public void enqueueTask(Runnable task)
{
try
{
taskQueue.put(task);
}
catch (InterruptedException e)
{
// should not happen
e.printStackTrace();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy