progressdata.java

来自「本程序在Unix_Linux环境下用Java语言编写的文件下载程序」· Java 代码 · 共 59 行

JAVA
59
字号
package loader.data;/** * * @author juddy */public class ProgressData {    public int MIN;    public int MAX;        private int currentLength;    /**     * the following methods including constructors is used to constructe the object.     * must min <= cur_len <= max     */    public ProgressData( int min, int max, int cur_len ){        MIN = min;        MAX = max;                this.currentLength = cur_len;    }        public ProgressData( int min, int max ){        this( min, max, 0 );    }        public ProgressData(){        MIN = 0;        MAX = 0;        this.currentLength = 0;    }    /**     * when getting MIN, MAX , you just through ProgressData.MIN or ProgressData.MAX     */    public void setMin( int min ){        MIN = min;    }        public void setMax( int max ){        MAX = max;    }    /**     * when the other thread be updating the currentLength's value,      * this thread must be blocked to wait.     */    synchronized public int getCurrentLength(){        return this.currentLength;    }    /**     * when the other thread be getting the currentLength's value,     * this thread must be blocked to wait.     */    synchronized public void setCurrentLength( int inc_value ){        if( this.currentLength < MAX ){            this.currentLength += inc_value;        }    }}

⌨️ 快捷键说明

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