摘 要
現實世界中的很多過程都具有多條線索同時動作的特性。Java語言的一大特性就是內置對多線程的支持。多線程是指同時存在幾個執行體,按幾條不同的執行線索共同工作的情況,它使得編程人員可以很方便地開發出具有多線程功能、能同時處理多個任務的功能強大的應用程序。一些同時運行的線程需要共享數據,因此每個線程就必須要考慮其它與它一起共享數據的線程的狀態與行為,這就是線程安全的問題。為了對Java多線程與線程安全機制進行研究與實踐,特此設計一個基于Http 協議的支持多線程斷點續傳的下載程序。此下載程序由下載任務模塊、設置模塊以及系統幫助模塊組成。通過Apache Jakarta Commons下的子項目HttpClient包對Http協議進行支持,從而下載服務器端的資源。程序提供多線程斷點續傳功能,在完成下載過程中使用多線程技術可以較大幅度地提高下載的速度。
關鍵詞:多線程;線程安全;斷點續傳
The Practice of Java Multithreading and Thread Security---- Download Tool with Broken/Resume Function based on http
Abstract
In real world, many processes have the characteristic that multi-strip clue act at the same time. The Java language has a major characteristic of embedded multithread support. Multithreading is the status that exist several implementation body at the same time, according to several different clues to the implementation of the joint work, It means that programmers can easily produce more threads development functions, It can also deal with a number of tasks powerful application. Running some of the threads need to share data, So each thread must consider other with it to share the data with the state of the thread, This is the thread safety. To Java multithreading and security mechanisms to conduct research and practice, Design hereby Http agreement on the support multithreading download procedures. This download procedures comprises of downloading task module, setting module and helping system module. With Http support of HttpClient, a subproject of Apache Jakarta Commons, it can download resources coming from web server. The procedure provides the Multi-threaded broken/resume functionality, in the process of completes downloading to use the multi-thread technology can greatly boost download speed.