/** * Create a scheduler thread that runs the specified runnable exactly once.<p> * * @param pool the pool to use * @param threadGroup the thread group to use * @param threadName the name for the thread * @param prio the priority of the thread * @param isDaemon controls if this should be a deamon thread or not * @param runnable the runnable to run */ CmsSchedulerThread( CmsSchedulerThreadPool pool, ThreadGroup threadGroup, String threadName, int prio, boolean isDaemon, Runnable runnable) { super(threadGroup, threadName); m_run = true; m_pool = pool; m_runnable = runnable; setPriority(prio); setDaemon(isDaemon); }
/** * Create a scheduler thread that runs the specified runnable exactly once.<p> * * @param pool the pool to use * @param threadGroup the thread group to use * @param threadName the name for the thread * @param prio the priority of the thread * @param isDaemon controls if this should be a deamon thread or not * @param runnable the runnable to run */ CmsSchedulerThread( CmsSchedulerThreadPool pool, ThreadGroup threadGroup, String threadName, int prio, boolean isDaemon, Runnable runnable) { super(threadGroup, threadName); m_run = true; m_pool = pool; m_runnable = runnable; setPriority(prio); setDaemon(isDaemon); }
/** * Loop, executing targets as they are received.<p> */ @Override public void run() { boolean runOnce = (m_runnable != null); while (m_run) { setPriority(m_pool.getThreadPriority()); try { if (m_runnable == null) { m_runnable = m_pool.getNextRunnable(); } if (m_runnable != null) { m_runnable.run(); } } catch (InterruptedException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_THREAD_INTERRUPTED_1, getName()), e); } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.LOG_THREAD_ERROR_1, getName()), t); } finally { if (runOnce) { m_run = false; } m_runnable = null; } } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_THREAD_SHUTDOWN_1, getName())); } }
/** * Loop, executing targets as they are received.<p> */ @Override public void run() { boolean runOnce = (m_runnable != null); while (m_run) { setPriority(m_pool.getThreadPriority()); try { if (m_runnable == null) { m_runnable = m_pool.getNextRunnable(); } if (m_runnable != null) { m_runnable.run(); } } catch (InterruptedException e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_THREAD_INTERRUPTED_1, getName()), e); } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.LOG_THREAD_ERROR_1, getName()), t); } finally { if (runOnce) { m_run = false; } m_runnable = null; } } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_THREAD_SHUTDOWN_1, getName())); } }