⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quenelistener.java

📁 封装了SQL、Socket、WAP、MIME等功能的通用组件
💻 JAVA
字号:
/**
 * <p>队列监听器</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: www.lazybug.com</p>
 * @author 刘学
 * @version 0.5
 */
package org.lazybug.util;
import java.util.*;

public abstract class QueneListener extends Listener
{
    public LinkedList quene;
    public long _duration_busy = 0;         //处理请求的计时器
    public long _duration_global = 0;  //全局计时器
    public int busy_count = 0;   //联系人处理请求的个数计数器
    public double speed = 0.0; //每秒钟处理请求的速度
    public double busy = 0.0;
    public static final int COUNT_PACKET_PENDING = 200;

    public QueneListener()
    {
        this._duration_global = System.currentTimeMillis();
        quene = new LinkedList();
    }

    public synchronized void post(Object object)
    {
        this.quene.addLast(object);
        this.notify();
    }

    public synchronized final Object peek()
    {
        try
        {
            return this.quene.removeFirst();
        }
        catch (NoSuchElementException e)
        {
            return null;
        }
    }

    /**
     * 计算空闲率和性能速度的方法
     */
    public void capability()
    {
        this._duration_global = System.currentTimeMillis() - this._duration_global;
        //每秒钟处理速度
        this.speed = ( (double) (COUNT_PACKET_PENDING*1000) / _duration_busy ) ;
        //计算线程的使用率
        this.busy = ( (double) (this._duration_busy * 100)) / this._duration_global; //空闲率
        this.busy_count = 0;
        this._duration_busy = 0;
        this._duration_global = System.currentTimeMillis();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -