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

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

?? leasemanager.java

?? 一個java方面的消息訂閱發送的源碼
?? JAVA
字號:
/**
 * Redistribution and use of this software and associated documentation
 * ("Software"), with or without modification, are permitted provided
 * that the following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright
 *    statements and notices.  Redistributions must also contain a
 *    copy of this document.
 *
 * 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.
 *
 * 3. The name "Exolab" must not be used to endorse or promote
 *    products derived from this Software without prior written
 *    permission of Exoffice Technologies.  For written permission,
 *    please contact info@exolab.org.
 *
 * 4. Products derived from this Software may not be called "Exolab"
 *    nor may "Exolab" appear in their names without prior written
 *    permission of Exoffice Technologies. Exolab is a registered
 *    trademark of Exoffice Technologies.
 *
 * 5. Due credit should be given to the Exolab Project
 *    (http://www.exolab.org/).
 *
 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESSED 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
 * EXOFFICE TECHNOLOGIES OR ITS 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.
 *
 * Copyright 2000-2005 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: LeaseManager.java,v 1.2 2005/03/18 03:47:30 tanderson Exp $
 */
package org.exolab.jms.lease;


import org.exolab.jms.service.BasicService;
import org.exolab.jms.service.ServiceException;
import org.exolab.jms.service.ServiceState;
import org.exolab.jms.common.util.OrderedQueue;


/**
 * The LeaseManager is responsible for creating and managing the lease objects.
 * The Leasemanager is a singleton. When a BaseLease object is created it is
 * added to the queue according to the duration (i.e. leases with shorter
 * durations are placed at the top of the queue.
 * <p>
 * When the lease expires the LeeaseManager calls the leasee's associated
 * listener(s).
 *
 * @version     $Revision: 1.2 $ $Date: 2005/03/18 03:47:30 $
 * @author      <a href="mailto:jima@comware.com.au">Jim Alateras</a>
 */
public class LeaseManager extends BasicService {

    /**
     * The name of the LeaseManagerThread that scans and removes expired leases
     */
    private static final String LEASE_MANAGER_THREAD_NAME =
        "LeaseManagerReaper";

    /**
     * An ordered list of leases.
     */
    private OrderedQueue _queue = null;

    /**
     * The singleton instance of the LeaseManager.
     */
    private static LeaseManager _instance = new LeaseManager();

    /**
     * Helper for waiting for leases to expire.
     */
    private final Object _waiter = new Object();


    /**
     * Create a new sorted tree set using the lease comparator as the
     * sorting functor.
     */
    protected LeaseManager() {
        super(LEASE_MANAGER_THREAD_NAME);
        _queue = new OrderedQueue(new LeaseComparator());
    }

    /**
     * Return the singleton instance of the LeaseManager
     *
     * @return LeaseManager
     */
    public static LeaseManager instance() {
        return _instance;
    }

    /**
     * Add a lease.
     *
     * @param lease the lease to add
     */
    public void addLease(BaseLease lease) {
        synchronized (_queue) {
            _queue.add(lease);
            if (_queue.firstElement() == lease) {
                // inserted before the first element, so reset scan
                synchronized (_waiter) {
                    _waiter.notify();
                }
            }
        }
    }

    /**
     * Remove the specified lease.
     *
     * @param       lease           lease to remove
     * @return      boolean         true if successful; false otherwise
     */
    public boolean removeLease(BaseLease lease) {
        boolean result = false;

        synchronized (_queue) {
            result = _queue.remove(lease);
        }
        if (result) {
            synchronized (_waiter) {
                _waiter.notify();
            }
        }

        return result;
    }

    /**
     * Renew the lease on the specified object
     *
     * @param lease the lease to renew
     * @param duration the new duration of the lease in ms
     */
    public BaseLease renewLease(BaseLease lease, long duration) {
        BaseLease newlease = null;

        if ((lease != null) && (duration > 0)) {
            synchronized (_queue) {
                // check that the lease hasn't expired yet.
                if (_queue.remove(lease)) {
                    lease.setDuration(duration);
                    _queue.add(lease);
                    newlease = lease;
                    synchronized (_waiter) {
                        _waiter.notify();
                    }
                }
            }
        }

        return newlease;
    }

    /**
     * Remove all the leases from the queue. Do not expire any of them
     */
    public void removeAll() {
        synchronized (_queue) {
            _queue.clear();
        }
    }

    /**
     * The run method will search for expired leases, remove them from the
     * list and notify listeners
     */
    public void run() {
        while (getState() != ServiceState.STOPPED) {
            expire();

            // wait until a lease is available, or the service is terminated
            synchronized (_waiter) {
                try {
                    _waiter.wait();
                } catch (InterruptedException ignore) {
                }
            }
        }
    }

    /**
     * Stop the service.
     *
     * @throws ServiceException if the service fails to stop
     */
    public void stop() throws ServiceException {
        super.stop();
        synchronized (_waiter) {
            _waiter.notifyAll();
        }
    }

    /**
     * Expires active leases
     */
    protected void expire() {
        while (_queue.size() > 0) {
            BaseLease lease = null;
            boolean expired = false;
            synchronized (_queue) {
                lease = (BaseLease) _queue.firstElement();
                if (lease == null) {
                    continue;
                }
                
                if (lease.getExpiryTime() <= System.currentTimeMillis()) {
                    // remove from the list and notify listeners
                    _queue.removeFirstElement();
                    expired = true;
                }
            }

            if (expired) {
                lease.notifyLeaseExpired();
            } else {
                // wait until the first element in the list is
                // ready to expire
                long time = lease.getExpiryTime() - 
                    System.currentTimeMillis();
                
                if (time > 0) {
                    try {
                        synchronized (_waiter) {
                            _waiter.wait(time);
                        }
                    } catch (InterruptedException ignore) {
                    }
                }
            }
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品自在欧美一区| 蜜臀av亚洲一区中文字幕| 国产精品日韩成人| 国产日韩av一区二区| 国产欧美一区二区在线观看| 日韩免费高清av| 在线免费精品视频| 成人精品一区二区三区四区| 久久国产人妖系列| 国产精品白丝jk白祙喷水网站| 韩国三级在线一区| heyzo一本久久综合| 欧美视频三区在线播放| 精品免费国产一区二区三区四区| 日韩视频一区在线观看| 国产欧美日本一区视频| 亚洲一区二区三区在线播放| 美女诱惑一区二区| 91麻豆精品在线观看| 日韩一级高清毛片| 亚洲欧美另类图片小说| 美女国产一区二区| 色综合久久久久| 精品国产成人在线影院| 亚洲h动漫在线| 不卡影院免费观看| 久久亚洲捆绑美女| 日韩福利视频网| 91国在线观看| 国产精品萝li| 国产露脸91国语对白| 欧美大片在线观看一区二区| 亚洲综合无码一区二区| 成人免费毛片片v| 久久精品亚洲国产奇米99| 日产欧产美韩系列久久99| 日本韩国欧美国产| 亚洲精品国久久99热| 成人性生交大片免费看中文网站| 精品黑人一区二区三区久久 | 日韩成人av影视| 在线观看日韩av先锋影音电影院| 中文在线免费一区三区高中清不卡| 免费成人在线网站| 91天堂素人约啪| 日韩一本二本av| 轻轻草成人在线| www久久久久| 国产黄色精品网站| 亚洲色图.com| 欧美亚洲日本一区| 美女视频黄免费的久久 | 综合激情成人伊人| 欧美亚洲国产bt| 国产精品中文欧美| 亚洲欧美日韩国产综合在线| 欧美性xxxxxxxx| 精品一区二区精品| 亚洲欧美激情在线| 日韩欧美国产麻豆| 一本到不卡免费一区二区| 亚洲午夜电影网| 亚洲国产精品成人久久综合一区| 91在线观看高清| 精品制服美女久久| 一区二区三区在线视频观看 | 亚洲成av人在线观看| 国产亚洲欧洲997久久综合 | 中文字幕中文字幕中文字幕亚洲无线| 91官网在线观看| 国产成人啪免费观看软件| 亚洲第一主播视频| 中文字幕日韩欧美一区二区三区| 欧美日韩一区二区欧美激情| 国产盗摄女厕一区二区三区| 午夜国产精品影院在线观看| 国产精品人人做人人爽人人添| 91精品在线一区二区| 91国偷自产一区二区三区观看 | 91精品福利在线| 国产在线视频精品一区| 麻豆精品在线看| 中文字幕精品在线不卡| 成人黄色软件下载| 国产乱子伦一区二区三区国色天香 | 日韩精品一区二| 91精品国产麻豆| 欧美视频中文字幕| 欧美性猛片aaaaaaa做受| 欧美亚洲图片小说| 欧美日韩色综合| 日韩三级视频在线看| 3d成人动漫网站| 精品国产免费人成电影在线观看四季 | 欧美日韩五月天| 91精品国产一区二区人妖| 欧美成人a∨高清免费观看| 精品精品国产高清a毛片牛牛| 久久久久国产精品麻豆| 国产精品无遮挡| 亚洲国产精品久久人人爱| 日本亚洲天堂网| 春色校园综合激情亚洲| 91首页免费视频| 日韩美一区二区三区| 日韩毛片在线免费观看| 午夜精品久久久久影视| 国产乱国产乱300精品| 欧美视频自拍偷拍| 国产精品网曝门| 免费久久精品视频| 972aa.com艺术欧美| 日韩欧美在线综合网| 亚洲男人的天堂av| 国产尤物一区二区在线| 7777精品伊人久久久大香线蕉的 | 亚洲午夜影视影院在线观看| 亚洲精品你懂的| 国产精品亚洲а∨天堂免在线| 99久久国产综合精品女不卡| 日韩亚洲国产中文字幕欧美| 亚洲美女区一区| 91一区在线观看| 国产欧美日韩不卡| 国产综合色产在线精品| 欧美久久一二区| 亚洲精品免费视频| 日本久久电影网| 亚洲日本韩国一区| 色拍拍在线精品视频8848| 国产精品热久久久久夜色精品三区| 久久99国产精品成人| 精品乱码亚洲一区二区不卡| 日本午夜一本久久久综合| 91精品国产综合久久精品图片| 亚洲精品日日夜夜| 欧美日韩成人高清| 五月综合激情网| 精品裸体舞一区二区三区| 久久国产人妖系列| 国产精品伦理在线| 色婷婷精品久久二区二区蜜臀av | 91在线小视频| 亚洲国产人成综合网站| 欧美一区二区精品在线| 久久99精品久久久久婷婷| 久久久久久久综合狠狠综合| 懂色av一区二区在线播放| 一区二区三区产品免费精品久久75| 欧美日韩精品综合在线| 紧缚捆绑精品一区二区| 1024成人网| 欧美福利电影网| 福利电影一区二区| 日一区二区三区| 欧美国产综合一区二区| 欧美精品在线观看播放| 99热在这里有精品免费| 国产真实乱对白精彩久久| 精品噜噜噜噜久久久久久久久试看 | 亚洲综合免费观看高清完整版| 色婷婷久久久亚洲一区二区三区 | 欧美亚洲另类激情小说| 国内不卡的二区三区中文字幕| 一区二区三区美女视频| 2020国产精品自拍| 日韩欧美一区在线| 欧美日韩午夜精品| 色综合婷婷久久| 99久久婷婷国产综合精品电影 | 日韩三级在线免费观看| 欧美综合一区二区三区| 成人av在线网站| 懂色中文一区二区在线播放| 国产成人综合在线观看| 日韩国产欧美在线播放| 日本午夜一本久久久综合| 日韩黄色免费网站| 美女视频免费一区| 精品亚洲成a人在线观看| 国产一区二区三区国产| 极品瑜伽女神91| 成人一区二区三区视频在线观看 | 国产色综合一区| 亚洲欧洲精品成人久久奇米网| 中文字幕综合网| 亚洲一区二区三区爽爽爽爽爽| 图片区小说区国产精品视频| 午夜久久久久久电影| 九九**精品视频免费播放| 岛国精品在线播放| 欧美三级午夜理伦三级中视频| 欧美老肥妇做.爰bbww| wwww国产精品欧美| 亚洲一区二区三区四区在线免费观看 | 亚洲无人区一区| 国产91在线观看| 欧美日韩国产综合久久 | 国产精品综合一区二区三区| 91丝袜美腿高跟国产极品老师 |