當前位置: 首頁>>代碼示例>>Java>>正文


Java Timer.purge方法代碼示例

本文整理匯總了Java中java.util.Timer.purge方法的典型用法代碼示例。如果您正苦於以下問題:Java Timer.purge方法的具體用法?Java Timer.purge怎麽用?Java Timer.purge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Timer的用法示例。


在下文中一共展示了Timer.purge方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: StopTask

import java.util.Timer; //導入方法依賴的package包/類
/**
 * 停止當前任務(隻會由button UI觸發, 肯定為當前選中task)
 */
public void StopTask() {
    this.taskListModel.MarkTaskStatus(currentSelectTask.id, TaskStatus.STOPPED);
    NotifyAllObservers();

    // 停止定時抓取任務
    Timer timer = ApsvTimerManager.GetTimer(currentSelectTask.id);
    if (timer != null) {
        timer.cancel();
        timer.purge();
    }
    ApsvTimerManager.ClearStartTime(currentSelectTask.id);
}
 
開發者ID:thundernet8,項目名稱:AlipayOrdersSupervisor-GUI,代碼行數:16,代碼來源:RunTasksModel.java

示例2: copyInputToOutputStream

import java.util.Timer; //導入方法依賴的package包/類
/**
 * This copies the downloaded data from the InputStream to the OutputStream,
 * keeping track of the number of bytes that have flowed through for the
 * progress counter.
 */
private void copyInputToOutputStream(InputStream input, int bufferSize, OutputStream output)
        throws IOException, InterruptedException {
    Timer timer = new Timer();
    try {
        bytesRead = 0;
        totalBytes = totalDownloadSize();
        byte[] buffer = new byte[bufferSize];

        timer.scheduleAtFixedRate(progressTask, 0, 100);

        // Getting the total download size could potentially take time, depending on how
        // it is implemented, so we may as well check this before we proceed.
        throwExceptionIfInterrupted();

        while (true) {

            int count;
            if (input.available() > 0) {
                int readLength = Math.min(input.available(), buffer.length);
                count = input.read(buffer, 0, readLength);
            } else {
                count = input.read(buffer);
            }

            throwExceptionIfInterrupted();

            if (count == -1) {
                Utils.debugLog(TAG, "Finished downloading from stream");
                break;
            }
            bytesRead += count;
            output.write(buffer, 0, count);
        }
    } finally {
        downloaderProgressListener = null;
        timer.cancel();
        timer.purge();
        output.flush();
        output.close();
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:47,代碼來源:Downloader.java


注:本文中的java.util.Timer.purge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。