All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sdmlib.models.taskflows.SDMThread Maven / Gradle / Ivy

Go to download

SDMLib is a light weight modeling library. SDMLib intentionally comes without any tool or editor.

There is a newer version: 2.3.2341
Show newest version
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