摘 要
現(xiàn)實世界中的很多過程都具有多條線索同時動作的特性。Java語言的一大特性就是內(nèi)置對多線程的支持。多線程是指同時存在幾個執(zhí)行體,按幾條不同的執(zhí)行線索共同工作的情況,它使得編程人員可以很方便地開發(fā)出具有多線程功能、能同時處理多個任務(wù)的功能強(qiáng)大的應(yīng)用程序。一些同時運行的線程需要共享數(shù)據(jù),因此每個線程就必須要考慮其它與它一起共享數(shù)據(jù)的線程的狀態(tài)與行為,這就是線程安全的問題。為了對Java多線程與線程安全機(jī)制進(jìn)行研究與實踐,特此設(shè)計一個基于Http 協(xié)議的支持多線程斷點續(xù)傳的下載程序。此下載程序由下載任務(wù)模塊、設(shè)置模塊以及系統(tǒng)幫助模塊組成。通過Apache Jakarta Commons下的子項目HttpClient包對Http協(xié)議進(jìn)行支持,從而下載服務(wù)器端的資源。程序提供多線程斷點續(xù)傳功能,在完成下載過程中使用多線程技術(shù)可以較大幅度地提高下載的速度。
關(guān)鍵詞:多線程;線程安全;斷點續(xù)傳
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.