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

📄 datapool.java~14~

📁 短信网关发送接受平台。
💻 JAVA~14~
字号:
package Utilities;
import java.util.*;
import Config;
/**
 * <p>Title: sms_statistics</p>
 * <p>Description: InHand XMLCenter 短信服务平台计费统计程序</p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: 北京映翰通网络技术有限公司</p>
 * @author 韩传俊 shock2000@21cn.com
 * @version 1.0
 */

public class DataPool {
        private Vector pipe;
        private int capacity;
        private int size;
        public boolean has_elements=false;

        public DataPool() {
                pipe=new Vector();
                this.size=0;
                this.capacity=100;
        }

        public DataPool(int capacity){
                pipe=new Vector();
                this.capacity=capacity;
                this.size=0;
        }

        public int getSize(){
                return this.size;
        }

        public boolean isFull(){
                if (this.capacity>this.size)
                        return false;
                else
                        return true;
        }

        public boolean isEmpty(){
                if (this.size==0)
                        return true;
                else
                        return false;
        }

        public synchronized boolean push(Object o){
               while(this.size==this.capacity){
                        try{
                                wait();
                        }catch(Exception e){
                                e.printStackTrace();
                        }
                }
                this.pipe.addElement(o);
                this.size++;
                try{
                        notifyAll();
                }catch(Exception e){
                        e.printStackTrace();
                }
                //this.has_elements=true;
                return true;
/*
                if (this.size<this.capacity){
                        this.pipe.addElement(o);
                        this.size++;
                        return true;
                }else{
                        return false;
                }
*/        }

        public synchronized Object pop(){
               //System.out.println("===========pop==========");
                //if (this.has_elements){
                        while(this.size<=0){
                                try{
                                        //if(this.has_elements){
                                                //System.out.println("wait");
                                                wait();
                                                //System.out.println("wake");
                                        //}
                                }catch(Exception e){
                                        e.printStackTrace();
                                }
                        }
                //}

                Object result=null;

                if (this.size>0){
                        result=this.pipe.get(0);
                        this.pipe.remove(0);
                        this.size--;
                }
                try{
                        notifyAll();
                }catch(Exception e){
                        e.printStackTrace();
                }
                return result;
/*
                Object result=null;

                if (this.size>0){

                        result=this.pipe.get(0);
                        this.pipe.remove(0);
                        this.size--;
                }
                return result;
*/          }

        public void release(){
                this.pipe.removeAllElements();
                this.pipe=null;
        }

        public static void main(String[] args) {
               // DataPool dataPool1 = new DataPool();
        }


}

⌨️ 快捷键说明

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