?? piece.java
字號:
/* * 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; // 起始點的指針位置 private long pos; // 當前完成度所在的指針位置 private long end; // 終結點的指針位置 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; } /** * 切割出一塊新的區域 * @return */ public synchronized Piece cutPiece() { // 如果當前區塊還有大于xK的數據未下載完,則允許切割出分塊 long toCut = end - pos; if (toCut > (1024 * 10)) { long s; // 起點 long e; // 終點 s = (long) (pos + Math.ceil(toCut / 2)); e = end; end = s - 1; Piece piece = new Piece(s, s, e); return piece; } return null; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -