亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cmsschedulerthreadpool.java

?? cms是開源的框架
?? JAVA
字號:
/*
 * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/scheduler/CmsSchedulerThreadPool.java,v $
 * Date   : $Date: 2006/03/27 14:52:20 $
 * Version: $Revision: 1.12 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * 
 * This library is based to some extend on code from the 
 * OpenSymphony Quartz project. Original copyright notice:
 * 
 * Copyright James House (c) 2001-2005
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met: 1.
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer. 2. Redistributions in
 * binary form must reproduce the above copyright notice, this list of
 * conditions and the following disclaimer in the documentation and/or other
 * materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.opencms.scheduler;

import org.opencms.main.CmsLog;

import org.apache.commons.logging.Log;

import org.quartz.SchedulerConfigException;
import org.quartz.spi.ThreadPool;

/**
 * Simple thread pool used for the Quartz scheduler in OpenCms.<p>
 * 
 * @author Alexander Kandzior 
 * @author James House
 * @author Juergen Donnerstag
 *
 * @version $Revision: 1.12 $ 
 * 
 * @since 6.0.0 
 */
public class CmsSchedulerThreadPool implements ThreadPool {

    /** The log object for this class. */
    private static final Log LOG = CmsLog.getLog(CmsSchedulerThreadPool.class);

    private int m_currentThreadCount;

    private boolean m_inheritGroup;

    private boolean m_inheritLoader;

    private int m_initialThreadCount;

    private boolean m_isShutdown;

    private boolean m_makeThreadsDaemons;

    private int m_maxThreadCount;

    private Runnable m_nextRunnable;

    private Object m_nextRunnableLock;

    private ThreadGroup m_threadGroup;

    private String m_threadNamePrefix;

    private int m_threadPriority;

    private CmsSchedulerThread[] m_workers;

    /**
     * Create a new <code>CmsSchedulerThreadPool</code> with default values.
     * 
     * This will create a pool with 0 initial and 10 maximum threads running 
     * in normal priority.<p>
     * 
     * @see #CmsSchedulerThreadPool(int, int, int)
     */
    public CmsSchedulerThreadPool() {

        this(0, 10, Thread.NORM_PRIORITY);
    }

    /**
     * Create a new <code>CmsSchedulerThreadPool</code> with the specified number
     * of threads that have the given priority.
     * 
     * The OpenCms scheduler thread pool will initially start with provided number of
     * active scheduler threads.
     * When a thread is requested by the scheduler, and no "free" threads are available,
     * a new thread will be added to the pool and used for execution. The pool 
     * will be allowed to grow until it has reached the configured number 
     * of maximum threads.<p>
     * 
     * @param initialThreadCount the initial number of threads for the pool
     * @param maxThreadCount maximum number of threads the pool is allowed to grow
     * @param threadPriority the thread priority for the scheduler threads
     * 
     * @see java.lang.Thread
     */
    public CmsSchedulerThreadPool(int initialThreadCount, int maxThreadCount, int threadPriority) {

        m_inheritGroup = true;
        m_inheritLoader = true;
        m_nextRunnableLock = new Object();
        m_threadNamePrefix = "OpenCms: Scheduler Thread ";
        m_makeThreadsDaemons = true;
        m_initialThreadCount = initialThreadCount;
        m_currentThreadCount = 0;
        m_maxThreadCount = maxThreadCount;
        m_threadPriority = threadPriority;
    }

    /**
     * @see org.quartz.spi.ThreadPool#getPoolSize()
     */
    public int getPoolSize() {

        return m_currentThreadCount;
    }

    /**
     * Returns the thread priority of the threads in the scheduler pool.<p>
     * 
     * @return the thread priority of the threads in the scheduler pool 
     */
    public int getThreadPriority() {

        return m_threadPriority;
    }

    /**
     * @see org.quartz.spi.ThreadPool#initialize()
     */
    public void initialize() throws SchedulerConfigException {

        if (m_maxThreadCount <= 0 || m_maxThreadCount > 200) {
            throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_MAX_THREAD_COUNT_BOUNDS_0));
        }
        if (m_initialThreadCount < 0 || m_initialThreadCount > m_maxThreadCount) {
            throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_INIT_THREAD_COUNT_BOUNDS_0));
        }
        if (m_threadPriority <= 0 || m_threadPriority > 9) {
            throw new SchedulerConfigException(Messages.get().getBundle().key(Messages.ERR_SCHEDULER_PRIORITY_BOUNDS_0));
        }

        if (m_inheritGroup) {
            m_threadGroup = Thread.currentThread().getThreadGroup();
        } else {
            // follow the threadGroup tree to the root thread group
            m_threadGroup = Thread.currentThread().getThreadGroup();
            ThreadGroup parent = m_threadGroup;
            while (!parent.getName().equals("main")) {
                m_threadGroup = parent;
                parent = m_threadGroup.getParent();
            }
            m_threadGroup = new ThreadGroup(parent, this.getClass().getName());
        }

        if (m_inheritLoader) {
            LOG.debug(Messages.get().getBundle().key(
                Messages.LOG_USING_THREAD_CLASSLOADER_1,
                Thread.currentThread().getName()));
        }

        // create the worker threads and start them
        m_workers = new CmsSchedulerThread[m_maxThreadCount];
        for (int i = 0; i < m_initialThreadCount; ++i) {
            growThreadPool();
        }
    }

    /**
     * Run the given <code>Runnable</code> object in the next available
     * <code>Thread</code>.<p>
     * 
     * If while waiting the thread pool is asked to
     * shut down, the Runnable is executed immediately within a new additional
     * thread.<p>
     * 
     * @param runnable the <code>Runnable</code> to run
     * @return true if the <code>Runnable</code> was run
     */
    public boolean runInThread(Runnable runnable) {

        if (runnable == null) {
            return false;
        }

        if (m_isShutdown) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_THREAD_POOL_UNAVAILABLE_0));
            return false;
        }

        if ((m_currentThreadCount == 0) || (m_nextRunnable != null)) {
            // try to grow the thread pool since other runnables are already waiting
            growThreadPool();
        }

        synchronized (m_nextRunnableLock) {

            // wait until a worker thread has taken the previous Runnable
            // or until the thread pool is asked to shutdown
            while ((m_nextRunnable != null) && !m_isShutdown) {
                try {
                    m_nextRunnableLock.wait(1000);
                } catch (InterruptedException e) {
                    // can be ignores
                }
            }

            // during normal operation, not shutdown, set the nextRunnable
            // and notify the worker threads waiting (getNextRunnable())
            if (!m_isShutdown) {
                m_nextRunnable = runnable;
                m_nextRunnableLock.notifyAll();
            }
        }

        // if the thread pool is going down, execute the Runnable
        // within a new additional worker thread (no thread from the pool)
        // note: the synchronized section should be as short (time) as
        // possible as starting a new thread is not a quick action
        if (m_isShutdown) {
            new CmsSchedulerThread(
                this,
                m_threadGroup,
                m_threadNamePrefix + "(final)",
                m_threadPriority,
                false,
                runnable);
        }

        return true;
    }

    /**
     * Terminate any worker threads in this thread group.<p>
     * 
     * Jobs currently in progress will be allowed to complete.<p>
     */
    public void shutdown() {

        shutdown(true);
    }

    /**
     * Terminate all threads in this thread group.<p>
     * 
     * @param waitForJobsToComplete if true,, all current jobs will be allowed to complete
     */
    public void shutdown(boolean waitForJobsToComplete) {

        m_isShutdown = true;

        // signal each scheduler thread to shut down
        for (int i = 0; i < m_currentThreadCount; i++) {
            if (m_workers[i] != null) {
                m_workers[i].shutdown();
            }
        }

        // give waiting (wait(1000)) worker threads a chance to shut down
        // active worker threads will shut down after finishing their
        // current job
        synchronized (m_nextRunnableLock) {
            m_nextRunnableLock.notifyAll();
        }

        if (waitForJobsToComplete) {
            // wait until all worker threads are shut down
            int alive = m_currentThreadCount;
            while (alive > 0) {
                alive = 0;
                for (int i = 0; i < m_currentThreadCount; i++) {
                    if (m_workers[i].isAlive()) {
                        try {
                            if (LOG.isDebugEnabled()) {
                                LOG.debug(Messages.get().getBundle().key(
                                    Messages.LOG_THREAD_POOL_WAITING_1,
                                    new Integer(i)));
                            }

                            // note: with waiting infinite - join(0) - the application 
                            // may appear to 'hang' 
                            // waiting for a finite time however requires an additional loop (alive)
                            alive++;
                            m_workers[i].join(200);
                        } catch (InterruptedException e) {
                            // can be ignored
                        }
                    }
                }
            }

            int activeCount = m_threadGroup.activeCount();
            if (activeCount > 0 && LOG.isInfoEnabled()) {
                LOG.info(Messages.get().getBundle().key(
                    Messages.LOG_THREAD_POOL_STILL_ACTIVE_1,
                    new Integer(activeCount)));
            }
            if (LOG.isDebugEnabled()) {
                LOG.debug(Messages.get().getBundle().key(Messages.LOG_THREAD_POOL_SHUTDOWN_0));
            }
        }
    }

    /**
     * Dequeue the next pending <code>Runnable</code>.<p>
     * 
     * @return the next pending <code>Runnable</code>
     * @throws InterruptedException if something goes wrong
     */
    protected Runnable getNextRunnable() throws InterruptedException {

        Runnable toRun = null;

        // Wait for new Runnable (see runInThread()) and notify runInThread()
        // in case the next Runnable is already waiting.
        synchronized (m_nextRunnableLock) {
            if (m_nextRunnable == null) {
                m_nextRunnableLock.wait(1000);
            }

            if (m_nextRunnable != null) {
                toRun = m_nextRunnable;
                m_nextRunnable = null;
                m_nextRunnableLock.notifyAll();
            }
        }

        return toRun;
    }

    /**
     * Grows the thread pool by one new thread if the maximum pool size 
     * has not been reached.<p>
     */
    private void growThreadPool() {

        if (m_currentThreadCount < m_maxThreadCount) {
            // if maximum number is not reached grow the thread pool
            synchronized (m_nextRunnableLock) {
                m_workers[m_currentThreadCount] = new CmsSchedulerThread(this, m_threadGroup, m_threadNamePrefix
                    + m_currentThreadCount, m_threadPriority, m_makeThreadsDaemons);
                if (m_inheritLoader) {
                    m_workers[m_currentThreadCount].setContextClassLoader(Thread.currentThread().getContextClassLoader());
                }
                // increas the current size
                m_currentThreadCount++;
                // notify the waiting threads
                m_nextRunnableLock.notifyAll();
            }
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国午夜理伦三级不卡影院| 91黄色免费版| 99久久99精品久久久久久| 欧美在线999| 国产视频一区二区在线观看| 亚洲国产精品久久人人爱蜜臀| 91精品午夜视频| 亚洲天堂免费看| 国产在线视频一区二区| 欧美三级中文字幕在线观看| 国产精品久久三区| 日本一道高清亚洲日美韩| 色成人在线视频| 中文字幕欧美日本乱码一线二线 | 99免费精品视频| 欧美性一级生活| 国产精品丝袜一区| 另类成人小视频在线| 欧美视频自拍偷拍| 亚洲色图第一区| 成人av在线一区二区| 久久久不卡网国产精品一区| 免费视频最近日韩| 欧美日本在线视频| 亚洲尤物视频在线| av中文字幕不卡| 国产精品免费视频网站| 粉嫩一区二区三区性色av| 久久久亚洲国产美女国产盗摄| 国产日韩精品一区二区三区在线| 久久亚洲一区二区三区明星换脸 | 欧美丰满少妇xxxbbb| 亚洲人亚洲人成电影网站色| 成人综合激情网| 日本一区二区电影| 国产精品 欧美精品| 日本一区二区三区在线不卡 | 欧美系列在线观看| 亚洲一区视频在线| 欧美午夜理伦三级在线观看| 亚洲在线免费播放| 欧美性生活久久| 日韩国产欧美在线观看| 欧美一区二区视频在线观看 | 99国产一区二区三精品乱码| 国产精品久久久久四虎| 成人免费毛片片v| 亚洲激情在线播放| 欧美日韩在线播放三区| 日本成人在线电影网| 26uuu成人网一区二区三区| 国产一区日韩二区欧美三区| 中文字幕av免费专区久久| 91在线丨porny丨国产| 亚洲精品福利视频网站| 91精品国产综合久久精品麻豆| 国产日韩欧美一区二区三区乱码| 亚洲另类春色国产| 欧美日韩在线免费视频| 蜜臀精品一区二区三区在线观看| av亚洲精华国产精华精华| 亚洲国产综合视频在线观看| 91精品国产高清一区二区三区| 亚洲视频在线一区二区| 欧美日韩国产另类一区| 国产一区视频网站| 亚洲综合区在线| 精品国产一区二区三区av性色| 午夜视频一区二区| 久久一二三国产| 在线视频中文字幕一区二区| 久久国产精品99精品国产| 国产精品毛片久久久久久久| 欧美午夜精品电影| 久久成人麻豆午夜电影| 亚洲色图在线视频| 精品免费日韩av| 欧洲av一区二区嗯嗯嗯啊| 激情久久五月天| 亚洲已满18点击进入久久| 日韩精品中文字幕一区二区三区 | 国产精品久久久久久久蜜臀 | 蜜臀av一区二区三区| 亚洲色欲色欲www在线观看| 日韩午夜激情视频| 91久久国产最好的精华液| 国产乱子伦视频一区二区三区| 日韩欧美在线不卡| 91影视在线播放| 国产福利91精品| 日本特黄久久久高潮| 最新不卡av在线| 久久嫩草精品久久久久| 欧美一级午夜免费电影| 色婷婷综合五月| 成人h动漫精品一区二| 精品一二线国产| 天天综合色天天综合| 亚洲欧美电影院| 中文字幕一区免费在线观看| 久久一区二区三区四区| 日韩精品一区二区三区在线播放| 狠狠久久亚洲欧美| 亚洲v中文字幕| 亚洲一本大道在线| 亚洲综合一二区| 亚洲激情中文1区| 亚洲精品一二三四区| 亚洲天堂成人网| 1000精品久久久久久久久| 久久精品免视看| 久久久久久毛片| 国产日韩欧美一区二区三区乱码| 一本在线高清不卡dvd| 97久久精品人人澡人人爽| 国产91精品久久久久久久网曝门| 亚洲欧洲精品一区二区精品久久久| 色诱视频网站一区| 91久久免费观看| 日本韩国欧美在线| 欧美综合欧美视频| 欧美日韩综合在线| 91精品国产全国免费观看| 日韩三级视频在线看| 日韩欧美一区二区免费| 精品国产自在久精品国产| 久久综合五月天婷婷伊人| 久久免费美女视频| 中文字幕精品三区| 一区二区三区四区不卡在线 | 一个色妞综合视频在线观看| 亚洲色图第一区| 亚洲国产综合色| 久久精品噜噜噜成人av农村| 激情五月激情综合网| 国产精品亚洲综合一区在线观看| 亚洲超碰97人人做人人爱| 麻豆免费精品视频| 成人做爰69片免费看网站| 91看片淫黄大片一级在线观看| 免费一区二区视频| 国产激情一区二区三区| 91在线国产福利| 538在线一区二区精品国产| 亚洲精品一区二区精华| 国产精品国产三级国产有无不卡 | 欧美精品粉嫩高潮一区二区| 在线播放91灌醉迷j高跟美女 | 成人激情黄色小说| 日本黄色一区二区| 欧美一区二区三区免费视频 | 欧美亚洲综合一区| 欧美一区二区三区四区视频| 久久只精品国产| 一区二区三区精品视频| 经典三级一区二区| 欧美曰成人黄网| 久久久亚洲精品石原莉奈| 亚洲国产成人porn| 国产一二精品视频| 欧美亚洲精品一区| 中文字幕巨乱亚洲| 麻豆91免费看| 一本到不卡精品视频在线观看| 91视视频在线直接观看在线看网页在线看 | 久久久国际精品| 亚洲精品日韩综合观看成人91| 国产精品卡一卡二| 蜜臀久久久久久久| 欧美中文字幕一区二区三区| 欧美激情综合五月色丁香| 图片区日韩欧美亚洲| 91麻豆福利精品推荐| 精品国产免费视频| 亚洲综合久久久| 99re这里只有精品6| 精品少妇一区二区三区免费观看| 精品国内片67194| 日韩在线观看一区二区| 懂色av一区二区三区免费看| 91精品久久久久久久99蜜桃 | 韩国av一区二区三区四区| 精品1区2区3区| 中文字幕在线不卡一区二区三区 | 美女久久久精品| 欧美片网站yy| 亚洲国产视频一区| 91蜜桃婷婷狠狠久久综合9色| 色婷婷综合在线| 亚洲人成网站在线| 成人一区二区三区视频| 精品日产卡一卡二卡麻豆| 美腿丝袜亚洲色图| 日韩一区二区三区四区| 免费久久99精品国产| 日韩免费高清视频| 极品尤物av久久免费看| 久久久久久久网| 国产精品一区在线观看你懂的| 99国产欧美另类久久久精品|