/** Override of Thread.run(). */ public void run() { boolean localEnd = false; while (!end && !localEnd) { try { Runnable runnable = (Runnable) queue.take(5000L); if (runnable == null) { detachCurrentThread(); localEnd = true; } else { runnable.run(); } } catch (RuntimeException e) { LOG.error("Error while delivering async message", e); } catch (InterruptedException e) { LOG.error("Error while delivering async message", e); } } }
public void send(Runnable runnable) { queue.offer(runnable); attachNewThreadIfNeccesary(); }