?? piece.java
字號(hào):
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package biz.tbuy.huliqing.jloading.downloader;/** * * @author huliqing */public class Piece { private long start; // 起始點(diǎn)的指針位置 private long pos; // 當(dāng)前完成度所在的指針位置 private long end; // 終結(jié)點(diǎn)的指針位置 public Piece(long start, long pos, long end) { this.start = start; this.pos = pos; this.end = end; } public synchronized long getEnd() { return end; } public synchronized void setEnd(long end) { this.end = end; } public synchronized long getPos() { return pos; } public synchronized void setPos(long pos) { this.pos = pos; } public synchronized long getStart() { return start; } public synchronized void setStart(long start) { this.start = start; } /** * 切割出一塊新的區(qū)域 * @return */ public synchronized Piece cutPiece() { // 如果當(dāng)前區(qū)塊還有大于xK的數(shù)據(jù)未下載完,則允許切割出分塊 long toCut = end - pos; if (toCut > (1024 * 10)) { long s; // 起點(diǎn) long e; // 終點(diǎn) s = (long) (pos + Math.ceil(toCut / 2)); e = end; end = s - 1; Piece piece = new Piece(s, s, e); return piece; } return null; }}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -