1 31 package org.objectweb.proactive.ic2d.util; 32 33 36 public class RunnableProcessor { 37 38 private static RunnableProcessor singletonInstance = new RunnableProcessor(); 39 40 private IC2DMessageLogger logger; 41 42 46 private RunnableProcessor() { 47 } 48 49 53 public static RunnableProcessor getInstance() { 54 return singletonInstance; 55 } 56 57 public void processRunnable(Runnable task, IC2DMessageLogger logger) { 58 processRunnable("Unamed Task", task, logger); 59 } 60 61 public void processRunnable(String taskName, Runnable task, IC2DMessageLogger logger) { 62 RunnerThread t = new RunnerThread(taskName, task); 63 this.logger = logger; 64 t.start(); 65 } 67 68 72 76 private class RunnerThread extends Thread { 77 78 private Runnable task; 79 80 public RunnerThread(String name, Runnable task) { 81 super(name); 82 this.task = task; 83 } 84 85 public void run() { 86 try { 87 task.run(); 88 } catch (Exception e) { 89 logger.log("The task "+getName()+" failed to execute to term", e); 90 } 91 } 92 93 } 94 95 } 96 | Popular Tags |