TW200529007A - System and method for sending data by multithread - Google Patents

System and method for sending data by multithread Download PDF

Info

Publication number
TW200529007A
TW200529007A TW93104245A TW93104245A TW200529007A TW 200529007 A TW200529007 A TW 200529007A TW 93104245 A TW93104245 A TW 93104245A TW 93104245 A TW93104245 A TW 93104245A TW 200529007 A TW200529007 A TW 200529007A
Authority
TW
Taiwan
Prior art keywords
data
thread
local
sent
database
Prior art date
Application number
TW93104245A
Other languages
Chinese (zh)
Inventor
jian-dong Wang
Original Assignee
Hon Hai Prec Ind Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hon Hai Prec Ind Co Ltd filed Critical Hon Hai Prec Ind Co Ltd
Priority to TW93104245A priority Critical patent/TW200529007A/en
Publication of TW200529007A publication Critical patent/TW200529007A/en

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention provides a system and method for sending data by multithread. The method comprises the following steps: A local application server runs a main application program; the main application program reads each data from a local database and startups a thread immediately, then reads next data and startups another new thread; after startup a certain thread, that is also said this thread, then startup HTTP to transfer these data to a remote database server; the thread obtains a state of these transferred data from the remote database server, and waits a message, which has been generated by the former thread, namely the document name; after having received the message, this thread updates a tag of these data in the local database, and then sends another message of these data to next thread to access the local database.

Description

200529007 五、發明說明(1) 【發明所屬之技術領域】 本發明係關於一種發送資料系統及方法,特別係關於 一種採用多線程機制來發送資料之系統及方法。 、 【先前技術】 當今一些高端伺服器一般採用複數處理器並用的方式 但也有一些作業糸統採用多線私機制來提高系統的性能 。所述之線程係指一個用於能夠完成特定功能的子應用程 式。所述之多線程是與單個線程相比較而言的,係^一個 飼服器可以同時處理複數應用程式的線程或一個應用程式 的複數線程。以往的作業系統採用單線程程式結構,其作 業原理疋·主應用程式有一個訊息循環,不斷從訊自、隊列 :讀取訊息來決定下一步所需完成的任務,該訊息;環一 奴是由一個子函數來完成的,主應用程式只有等待該子函 ^執行完返回後才能接收另外的訊息來執行。比如子函 =功,是在讀取一網路資料,主應用程式只有等待讀取完 =ΐ貝,才能接收下一個訊息。在執行該子函數過程中系 鈐而要等待一段時間,特別是讀取網路資料和等待用戶 别入時,系統有較多時間處於等待狀態。 儘管有些作業系統有並發作業功^,其實是利用了作 種i,中處理态的分時技術,而沒有真正應用到這種多線 時— > 然而在當今系統中,每一個程式可以同 務。=禝ί線程,這意味著一個程式可以同時完成複數任 多綠和另/疋在網路系統中,很多功能是可並發執行,使用 、、壬、制疋最佳選擇。例如網路傳輸資料的速度以及用 200529007 五、發明說明(2) 戶輸入速度較慢,可以用複數獨立的線程去完成資料的傳 輸,而不影響其他功能。由於資料藉由超文本傳輸協議( Hypertext Transfer Protocol,HTTP)進行發送和接收 回復’再加上數據證書加密等額外負擔,所以 帶寬的要求須大餘20 0Kbps。但通用INTERNET帶寬一般僅 有10Kbps至5 0Kbps,故採用一筆一筆發送資料的方式無法 滿足發送大量資料的時間要求。 關於多線程處理數據之支援技術曾揭露於丨9 9 9年〗2月 1 4曰公告之美國專利第6,〇 〇 3,0 6 6號,其專利名稱為,,複數 處理數據工作站之間的多線程分配系統(System For Distributing A Plurality Of Threads Associated With A Process Initiating By One Data Processing200529007 V. Description of the invention (1) [Technical field to which the invention belongs] The present invention relates to a system and method for transmitting data, and more particularly to a system and method for transmitting data using a multi-thread mechanism. [Previous technology] Some high-end servers today generally use a combination of multiple processors, but there are also some operations that use multi-line private mechanisms to improve system performance. The thread refers to a sub-application that can perform a specific function. The multi-threading is compared with a single thread, which means that one feeder can simultaneously process a plurality of application threads or a plurality of application threads. The previous operating system used a single-threaded program structure, and its operating principle 疋 The main application has a message loop, which continuously reads from the message and the queue: reads the message to determine the next task to be completed. The message; This is done by a sub-function, and the main application can only receive another message for execution after waiting for the sub-function to return. For example, the sub-function = work is reading data from a network. The main application can only receive the next message after waiting for reading. During the execution of this sub-function, it is necessary to wait for a period of time, especially when reading network data and waiting for the user to enter, the system has more time in the waiting state. Although some operating systems have concurrent operating functions ^, they actually use the time-sharing technology of the processing mode, and do not really apply this kind of multi-line time-> However, in today's systems, each program can be the same Business. = 禝 ίThread, which means that a program can complete multiple tasks at the same time. In a network system, many functions can be executed concurrently. The best choice is to use. For example, the speed of data transmission on the network and the use of 200529007 V. Invention Description (2) The user input speed is slow, and multiple independent threads can be used to complete the data transmission without affecting other functions. Because the data is sent and received through the Hypertext Transfer Protocol (HTTP), and the additional burden of data certificate encryption is added, the bandwidth requirement must be more than 200Kbps. However, the general Internet bandwidth is generally only 10Kbps to 50Kbps, so the method of sending data one by one cannot meet the time requirements for sending large amounts of data. Supporting technology for multi-threaded data processing was disclosed in 1999/99, U.S. Patent No. 6,003,06, published on February 14th, and its patent name is, between multiple data processing workstations. System For Distributing A Plurality Of Threads Associated With A Process Initiating By One Data Processing

Station Among Data Processing Stations ) ’’。該專利 揭露在電腦網路系統中一伺服器分配複數線程處理複數工 作站之間的數據,該複數線程之間採用了數據標記在處理 數據時進行跟縱與記錄。然而其不足之處在於該專利之發 明由於複數工作站需要多次執行處理數據之主應用程式, 而每次執行主應用程式需要額外時間,因此在處理大量數 據1^系要較長日守間’攸而無法滿足一些高性能系統處理數 據之時間要求。 為克服上述先前技術之不足,須提供一種採用多線程 發送 料系統及方法。其只需執行一次主應用程式即可啟 動複數線程同時進行資料傳輸,來縮短傳輸大量資料的傳 輸時間。Station Among Data Processing Stations) ''. The patent discloses that in a computer network system, a server allocates a plurality of threads to process data between a plurality of workstations, and data tags are used between the plurality of threads to track and record while processing data. However, the shortcoming is that the invention of the patent requires multiple workstations to execute the main application program that processes data multiple times, and each time the main application program is executed requires extra time, so it takes a long time to process a large amount of data. It is impossible to meet the time requirements of some high-performance systems for processing data. In order to overcome the above-mentioned shortcomings of the prior art, it is necessary to provide a multi-threaded sending system and method. It only needs to execute the main application once to start multiple threads to perform data transmission at the same time, thereby shortening the transmission time for transmitting a large amount of data.

第7頁 200529007 五、發明說明(3) 【發明内容】 本發明之主要目的在於提供一種多線程發送資料系統 及方法’其:^於發送大量資料時主應用程式只需啟動一 次L就能循J衣碩取多筆資料從而啟動複數線程,並採用複 數貝料通道同%傳輸的方式傳輸資料。所述之複數資料通 道的傳輸方式係指同時啟動複數線程並行傳輸多筆資料的 傳輸方式。 、本孓月之另目的在於提供多線程發送資料系統及方 法八可用於在夕線程進行資料傳輸時進行跟縱與記錄, 以及多線程間採用訊息通知機制來發送資料。 料系2達:t ϊ Γ明目❸’本發明提供一種多線程發送資 、一太地資斜廑 ί 統包括:一本地應用伺服器 i ,. —遇程貢料庫伺服器、一連接及網路。 其中,本地應用伺服器包括:一資料讀取模組用於=次 ΐ i其ί應的檔案名;—資料庫更新模組用於在資料庫ϊ ίΓ;ί;料之標記,所述之資料標記係用於 為"1”,若該筆資料未發送,則今筆、資料貝:亥筆貝枓標記記 及-線程運行模电用於上、上貝枓“記為”0";以 送資料,對每個線程中的資料傳輸狀態進行跟=發 以及對複數線程訪問資料庫時需建立的連 =, =程運行模組還包括一線程啟動子模組 =待 料庫用於儲存複數資料及每筆資料對應的播;名且和:以 第8頁 200529007 五、發明說明(4) 料對應的標記。遠程資料庫伺服器用於接收由本地應用伺 服為發送過來的資料及其對應的樓案名,並返回每一筆資 料傳輸狀態至本地應用伺服器。 本發明還提供一種多線程發送資料方法,該方法包括 如下步驟:(a)本地應用伺服器啟動主應用程式;(b)主應 用程式資料讀取模組從本地資料庫中讀取一筆需發送的資 料及其檔案名,該筆資料及其檔案名稱謂本次資料;(c ) 主應用程式讀取的本次資料啟動一個新的線程,該線程稱 謂本次線程,主應用程式並將讀取的本次資料及其檔案名 和上次資料棺案名提交本次該線程;(d )本次線程將已讀 取的本次資料及其檔案名置於發送狀態;(e )資料庫更新 模組於本地資料庫中更新已發送的資料之標記;(f )主應 用私式連續讀取多筆資料,並為讀取的每一筆資料啟動另 一個新的線程;(g)本次線程啟動HTTP將本次資料及其檔 案名傳輸至遠程資料庫伺服器;(h )對各個線程在傳輸資 料時進行跟蹤與記錄,並在複數線程之間採用訊息通知其 他線程訪問本地資料庫;(i )主應用程式判斷需發送的 料是否發送完畢。 ' 其中所述之對各個線程在傳輸資料時進行跟蹤與記錄 ,並在複數線程之間採用訊息通知其他線程訪問本地資 庫之步驟(h)還包括步驟:(ai )本次線程啟動Ηττρ,藉由 網路將已提交給本次線程的本次資料及其檔案名傳9至 程資料庫祠服器·,(M)遠程資料庫飼服器接收到本次資料 及其槽案名後,返回本次資料檔案名作為資料傳輸狀態至Page 7 200529007 V. Description of the invention (3) [Summary of the invention] The main purpose of the present invention is to provide a multi-threaded data transmission system and method. J Yishuo fetches multiple data to start multiple threads, and uses the same method to transmit data using multiple channels. The transmission method of the plural data channels refers to a transmission method in which plural threads are started simultaneously to transmit a plurality of data in parallel. The other purpose of this month is to provide a multi-threaded data transmission system and method eight, which can be used for tracking and recording when the thread is transmitting data, and using a message notification mechanism to send data between multiple threads. Material system 2: t ϊ Γ 明目 ❸ The present invention provides a multi-threaded sending resource, a land resource oblique system. The system includes: a local application server i ,.-Yucheng Gong material server, a connection And the internet. Among them, the local application server includes: a data reading module for the file name of the second time; the database update module is used to mark the data in the database, as described above. The data mark is used as "quot" 1. If the data is not sent, the current record, data record: Haibi beacon mark and-thread operation mode is used for "up" and "up" as "0"; In order to send data, follow the data transmission status in each thread and send connections to multiple threads to access the database =, = The process running module also includes a thread startup submodule = for the library Store multiple data and the corresponding broadcast of each data; name and sum: mark on page 8 200529007 5. Invention Description (4) corresponding to the data. The remote database server is used to receive the data sent by the local application server. And its corresponding building case name, and returns each data transmission status to the local application server. The invention also provides a multi-threaded data transmission method, which includes the following steps: (a) the local application server starts the main application program; (B) Main application The data reading module reads a piece of data to be sent and its file name from the local database, and the data and its file name are the current data; (c) the current data read by the main application program starts a new Thread, this thread refers to this thread, the main application will submit this read data and its file name and last data coffin name to this thread; (d) this thread will read this data And its file name is placed in the sending state; (e) the database update module updates the tags of the sent data in the local database; (f) the main application continuously reads multiple pieces of data privately, and A piece of data starts another new thread; (g) this thread starts HTTP to transmit this data and its file name to the remote database server; (h) tracks and records each thread when transmitting data, and Messages are used between multiple threads to notify other threads to access the local database; (i) the main application judges whether the materials to be sent have been sent. 'The tracking and recording of each thread when transmitting data is described in the above, and The step (h) of notifying other threads to access the local database by using messages between the plurality of threads includes the steps of: (ai) starting the current thread Ηττρ, and submitting the data and files submitted to the thread through the network. The name server 9 to the Cheng database database server, (M) The remote database server receives the data and its case name, and returns the name of the data file as the data transmission status to

第9頁 200529007Page 9 200529007

本地應用伺服益’(c 1 )線程跟蹤子模組接收該返回料 傳輸狀態;(dl)線程排隊子模組等待上次線程發出的名稱 為上次資料檔名之訊息;(el)線程通知子模組判斷是否收 到該訊息,若沒有收到該訊息,則線程排隊子模組繼等 待該訊息;若成功收到該訊息’則將上述返回的資 狀態記錄於本地資料庫中;(Π )線程通知子模組發出名稱 為本次資料播案名之訊息通知下一個排隊等待需連地 資料庫的線程訪問本地資料庫。 藉由貫施本發明,只需執行一次主應用程式即可啟動 複數線程同時進行資料傳輸,從而縮短資料的發送 到滿足發送大量資料的時間要求;且每一線程中資料^輸 狀態可以跟緞和記錄’故系統不會因太多的資料庫連 致系統性能下降以至停機。 【實施方式】 請參閱第一圖所示,係為本發明多線程發送資料系統 之硬體架構圖。該多線程發送資料系統包括一本地應用伺 服器1、一本地資料庫2、一遠程資料庫伺服器3、一'連接4 及網路5。本地應用伺服器1藉由連接4與本地資料庫2相連 接,且藉由網路5與遠程資料庫伺服器3相連接。該本地應 用伺服器1係用於啟動發送資料所需之主應用程式及複數w 線程(Thread),啟動超文本傳輸協議(HypertextThe local application servo benefits' (c 1) the thread tracking submodule receives the returned material transmission status; (dl) the thread queuing submodule waits for the message sent by the last thread whose name is the last data file name; (el) the thread notification The submodule determines whether the message is received. If it does not receive the message, the thread queues the submodule to wait for the message; if the message is successfully received, the above-mentioned returned asset status is recorded in the local database; ( Π) The thread notification submodule sends a message with the name of this data broadcast case to notify the next thread waiting for the database to be connected to the local database. By implementing the present invention, only a single execution of the main application program can start multiple threads to perform data transmission at the same time, thereby reducing the time required to send data to meet the requirements for sending a large amount of data; and the data input status in each thread can follow And record 'so the system will not cause system performance to be down due to too many databases. [Embodiment] Please refer to the first figure, which is a hardware architecture diagram of the multi-threaded data transmission system of the present invention. The multi-threaded data transmission system includes a local application server 1, a local database 2, a remote database server 3, a 'connection 4', and a network 5. The local application server 1 is connected to the local database 2 through connection 4, and is connected to the remote database server 3 through network 5. The local application server 1 is used to start the main application program and plural w threads required to send data, and to start the Hypertext Transfer Protocol (Hypertext

Transfer Protocol,HTTP)傳輸資料,接收Ηττρ從遠程 資料庫伺服器3返回的資料傳輸狀態,於本地資料庫2中記 錄該返回的狀態,並發出訊息通知其他需連接本地資料庫Transfer Protocol (HTTP) to transfer data and receive 传输 ττρ data transfer status returned from the remote database server 3, record the returned status in the local database 2, and send a message to notify other local databases that need to be connected

200529007 五、發明說明(6) 2的線程。所述之主應用程式係指運行於本地應用伺服器i 中可程式化的應用程式’其用於每次從本地資料庫2中讀 取一筆資料,即啟動一個用於發送資料的線程,然後於本 地資料庫2中讀取下一筆資料再啟動一個新的線程。所述 之線程係指一個用於發送資料及其對應檔案名的子應用程 式。該本地資料庫2用於儲存複數資料及其對應的檔案名 。5玄退程資料庫伺服器3用於接收從本地應用伺服器1發送 的資料及其對應的檔案名,並返回一資料傳輸狀態給本地 應用伺服器1。該連接4係一種資料庫連接,如開放式資料200529007 V. Description of the invention (6) 2 threads. The main application is a programmable application running on the local application server i, which is used to read a piece of data from the local database 2 each time, that is, to start a thread for sending data, and then Read the next data in local database 2 and start a new thread. The thread refers to a sub-application for sending data and its corresponding file name. The local database 2 is used to store plural data and their corresponding file names. 5 Xuan Departure Database Server 3 is used to receive the data sent from the local application server 1 and its corresponding file name, and return a data transmission status to the local application server 1. The connection 4 is a database connection, such as open data

庫連接(Open Database Connectivity ’ODBC),或者 Java 資料庫連接(Java Database Connectivity,JDBC) 等。網路5係為一種支援傳輸控制協議/網路協議( Transmission Control Protocol/Internet Protocol ? TCP/IP )之通訊網路,其可以為企業内部網(Intranet ) 、網際網路(Internet )或其他類型之通訊網路。Library connection (Open Database Connectivity 'ODBC), or Java Database Connectivity (JDBC). Network 5 is a communication network that supports Transmission Control Protocol / Internet Protocol (TCP / IP). It can be an intranet, the Internet, or other types of communication networks. Communication network.

請參閱第二圖所示,係為本發明多線程發送資料系統 之本地應用飼服器之軟體功能模組圖。該本地應用伺服器 1包括一資料讀取模組1 1、一資料庫更新模組丨2及一線程 運行模組1 3。其中,資料讀取模組π係用於從本地資料庫 2中讀取資料及其對應的檔案名。資料庫更新模組丨2係用 於在本地資料庫2中更新已向遠程資料庫伺服器3發送的資 料之標記。若該筆資料已發送,則於本地資料庫2中將該 筆資料之彳示§己更新為’’ 1 ” ’表示該筆資料已啟動發送,從 而避免主應用程式重復讀取已啟動線程發送的資料而再次Please refer to the second figure, which is a software function module diagram of the local application feeder of the multi-threaded data transmission system of the present invention. The local application server 1 includes a data reading module 11, a database update module 丨 2, and a thread running module 13. The data reading module π is used to read data from the local database 2 and its corresponding file name. The database update module 丨 2 is used to update the tag of the data sent to the remote database server 3 in the local database 2. If the data has been sent, the indication § of the data in the local database 2 has been updated to "1", which means that the data has been started to send, so as to avoid the main application repeatedly reading the started thread to send Information again

第11頁 200529007 五、發明說明(7) 為之啟動線程。線程運行模組1 3係用於為每讀取一筆資料 即啟動一個線程,採用複數資料通道同時傳輸的方式傳輸 資料,對每個線程中的資料傳輸狀態進行跟蹤和記錄,以 及對複數線程訪問本地資料庫2時需建立的連接進行排隊 等待。所述之複數資料通道的傳輸方式係指同時啟動複數 線程並行傳輸多筆資料的傳輸方式。該線程運行模組丨3包 括一線程啟動子模組1 3 1、一線程跟縱子模組1 3 2、一線程 排隊子模組1 3 3及一線程通知子模組1 3 4。其中,線程啟動 子模組1 3 1係用於每讀取一筆資料即啟動一個線程,在一 個主應用程式中同時啟動複數線程藉由複數資料通道向遠 程資料庫伺服器3傳輸該資料及其對應的權案名;線程跟 蹤子模組132係用於啟動HTTP將已提交給該線程的資^及 其槽案名傳輸至遠程資料庫伺服器3,對每個線程中的資 料傳輸狀態進行跟蹤,接收遠程資料庫伺服器3返回的資 料傳輸狀態,並記錄該返回的資料傳輪狀態;線程排隊子 模組1 3 3係用於藉由多線程機制中複數線程訪問本地資料 庫2時需建立的連接進行排隊等待,避免因太多的資料庫 ΪΪ導致系統性能下降以至停機’以及等待上次線程發出 、稱為上次貧料檔案名之訊息;線程通知子模组丨34传 用於將本次發送的資料之檔案名作為 r杈、,且?4係, 訪問本地資料庫2時需建立連接的線程,當下一個 排隊4待的線程接收到上次線程發出的訊氣 待的線程才與本地資料庫2建立連接。 心寸 ^ 請參閱第三圖所示,係為本發明多線程發送資料系統 200529007 五、發明說明(8) -- 之多線程運行機制示意圖。本地應用伺服器1啟動一主應 用程式,該主應用程式從本地資料庫2中循環讀取n筆資^斗 ,進而同時啟動η個線程,並採用n個資料通道同時發送n 筆資料。由於主應用程式每從本地資料庫2中讀取一Χ筆資 料提父給線程時,該線程都需與本地資料庫2建立一個連 接。為了避免因太多的線程連接資料庫導致系統性能下降 以至停機,故於線程啟動子模組丨3 i啟動一線程發送資料 後’線程排隊子模組133將需與本地資料庫2建立連接的線 程進行排隊等待,以及由線程通知子模組丨34發出本次資 料的插案名作為訊息通知下一個排隊等待的線程訪問本地 資料庫2。 請參閱第四圖所示,係為本發明多線程發送資料方法 之主應用程式作業流程圖。本地應用祠服器1啟動主應用 程式,並初始化所有需要發送資料的標記為” 0”。該^應 用程式係用於管控全部資料發送,且只啟動一次至全部資 料發送完畢後終止運行(步驟S100)。當資料讀取模組11 於本地資料庫2中讀取一筆需傳輸至遠程資料庫伺服器3的 資料(稱謂本次資料)及其對應的檔案名(步驟〇 1 )時 ’線程啟動子模組131立即為本次資料啟動一個新的線程 ’並將該本次資料及其檔案名和上次資料的檔案名提交給 該線程。所述之本次資料的檔案名係用於作為本次線程通 知下一個排隊等待訪問本地資料庫2的線程之訊息,以及 用於遠程資料庫伺服器3向本地應用伺服器1返回本次資料 傳輸狀態之訊息,所述之上次資料檔案名係用於上次線程Page 11 200529007 V. Description of the invention (7) Start the thread for it. The thread running module 1 and 3 are used to start a thread for each reading of a piece of data, and transmit data using a plurality of data channels simultaneously, track and record the data transmission status in each thread, and access to a plurality of threads. The connection to be established in the local database 2 is queued. The transmission method of the plurality of data channels refers to a transmission method in which a plurality of data are transmitted in parallel by simultaneously starting a plurality of threads. The thread running module 丨 3 includes a thread starting submodule 1 3 1, a thread and a vertical submodule 1 3 2, a thread queuing submodule 1 3 3, and a thread notification submodule 1 3 4. Among them, the thread starting sub-module 1 3 1 is used to start a thread for each read of a piece of data. In a main application program, a plurality of threads are simultaneously started to transmit the data and data to the remote database server 3 through a plurality of data channels. Corresponding case name; the thread tracking sub-module 132 is used to start HTTP to transmit the data submitted to the thread and its slot case name to the remote database server 3, and perform data transmission status in each thread Track and receive the data transmission status returned by the remote database server 3, and record the returned data transfer status; the thread queuing submodule 1 3 3 is used to access the local database 2 by multiple threads in the multi-thread mechanism The connections that need to be established are queued to avoid system performance degradation and downtime due to too many databases, and to wait for the last thread to send a message called the last lean file name; the thread notification submodule 丨 34 pass Use the file name of the data sent this time as r, and? For the 4th series, the connection thread needs to be established when accessing the local database 2. When the next thread waiting in queue 4 receives the message sent by the last thread, it will establish a connection with the local database 2. Mind ^ Please refer to the third figure, which is a schematic diagram of the multi-thread operation mechanism of the multi-threaded data transmission system of the present invention 200529007 V. Description of the Invention (8). The local application server 1 starts a main application program. The main application program cyclically reads n data items from the local database 2, and then starts n threads at the same time, and uses n data channels to send n data at the same time. Because each time the main application reads an X data from the local database 2 to the thread, the thread needs to establish a connection with the local database 2. In order to avoid system performance degradation and downtime caused by too many threads connecting to the database, the thread start submodule 丨 3 i starts a thread to send data and the 'thread queue submodule 133 will need to establish a connection with the local database 2. The thread waits in a queue, and the thread notification submodule 34 issues the name of this data as the message to notify the next queued thread to access the local database 2. Please refer to the fourth figure, which is a flowchart of the main application program operation of the multi-threaded data sending method of the present invention. The local application server 1 starts the main application and initializes all the tags to be sent as “0”. This application program is used to control the sending of all data, and only starts once and terminates the operation after sending all the data (step S100). When the data reading module 11 reads a piece of data (referred to as the current data) and its corresponding file name (step 〇1) to be transmitted to the remote database server 3 from the local database 2, the thread starts the submodule The group 131 immediately starts a new thread for this data and submits the current data and its file name and the file name of the last data to the thread. The file name of the current data is used as a message for the current thread to notify the next thread waiting to access the local database 2 and for the remote database server 3 to return the data to the local application server 1. Transmission status message, the last data file name mentioned is used for the last thread

200529007 五、發明說明(9) 通知本次線程訪問本地資料庫2之訊息(步驟si〇2 次線程將本次資料及其槽案名置為發送狀態(步驟MM ) 丄貝料庫更新模組I2於本地資料庫2中將處於發送 本次資料之標記更新為””,表示本次資料為 二 ^料(步驟sm)。主應用程式記錄已啟動發送/、的 1,即作+ 1運算,其中丄為一個計數變量(步驟si〇 :當線程啟動本次資料及其檔案名為發送狀態之步驟si〇 時,在資料庫更新模組12更新本次資料標記(步驟si〇4 的同時,本次線程立即啟動HTTP將本次資料及其資 名f輸至遠程資料庫伺服器3 (步驟sl〇6 )。本次資料田傳、 輸完畢後,主應用程式釋放本次線程,即作i = i — i 7曾 步驟S107)。接著主應用程式判斷是否i< = n,其中一 個固定值,其係指主應用程式在預先設定的一定門、、 内為連續讀取的每筆資料而啟動線程的個數,以避二二 多的線程連接本地資料庫2導致系統性能下降以至 ,20……(步驟si〇8)。若…說明在該時間 =間内主應用程式已達到啟動線程的預先設定的線程數 里’則主應用程式等待一段時間再讀取需發送的資 驟5109 );若i<n,說明在該時間將間隔内主應用程式還^ 未達到啟動線程的預先設定的個數,則主應用程式^^运 本地f料庫2中是否還有資料標記為"〇,,的資料(步驟S110 )。若在本地資料庫2中有資料標記為” 〇 ”的資料,士、 本地資料庫2中還有需發送的資料沒有發送完畢,况 步驟S1 0 1,即主應用程式繼續於本地資料庫中讀取資料°桿200529007 V. Description of the invention (9) Notify the thread to access the local database 2 (step sio2) The thread sets the data and its slot name to the sending state (step MM) I2 updates the flag of sending this data to "" in the local database 2 to indicate that this data is the second data (step sm). The main application records that the sending of / has been started, that is, +1 is calculated. , Where 丄 is a count variable (step si〇: when the thread starts the current data and its file name is the sending state of step si0, the database update module 12 updates the current data mark (while step si〇4) , This thread immediately starts HTTP to input this data and its name f to the remote database server 3 (step s106). After the data is transferred and uploaded, the main application releases this thread, that is, (I = i — i 7 in step S107). Then the main application judges whether i < = n, one of the fixed values, which means that each time the main application reads continuously in a certain preset gate, Data to start the number of threads to avoid two Two or more threads connected to the local database 2 caused the system performance to decrease to 20 ... (step si〇8). If ... it means that within this time = the main application program has reached the preset number of threads to start the thread within that time The main application waits for a period of time and then reads the data to be sent 5109); If i < n, it means that the main application has not yet reached the preset number of startup threads within the time interval ^, then the main application ^ ^ Whether there are any data marked with " 〇 ,, in the local f library 2 (step S110). If there is data marked with "〇" in the local database 2, the data in the local database 2 There is still no data to be sent. In step S101, the main application continues to read data from the local database.

第14頁 200529007Page 14 200529007

五、發明說明(10) 記為” 0”的資料及其檔案名,而為之重新啟動一個新的 程;若在本地資料庫2中沒有資料標記為"〇”的資料,锐 在本地資料庫2中需要發送的資料已經發送完畢, 用程式終止運行。 應 請參閱第五圖,係為本發明多線程發送資料方法 數線程傳輸資料之作業流程圖。由上述第四圖之主應用^ 式啟動一個線程將本次資料及其檔案名置為發送 : 驟sm後,在資料庫更新模組12更新本次資料標記口: S104 )的同時,線程跟蹤子模組132立即啟動Ηττρ將欠 讀取的資料及其資料檔案名傳輸至遠程資料庫伺 步驟sm)—。當遠程資料庫伺服器3成功接收到本次。資‘ ,遠私資料庫伺服态3以接收到的本次資料檔案名作為 資料傳輸狀態返回至本地應用伺服器丨,線程跟蹤子模組 取錄該返回的資料傳輸狀g,所述之資料傳輪 狀〜、係用π軚記的本次檔案名來表示其有兩種情況.— 資料傳輸成功,另一種表示資料傳輸失敗(步驟 ^ ^。線程排隊子模組133等待上次線程發出的名稱 ^ ^料檔案名之訊息(步驟sm ),並判斷是否收到該 ,心步驟S203 )。若線程排隊子模組133沒有收到該訊/ =:7,程排隊子模組133繼續等待上次線程發出的名稱 fmV料播案名之訊息(步驟S2°2);若線程排隊子模 、-且133成功收到該訊息,則線程跟蹤子模組132判斷本欠資 料輸成'力(步驟S2°4)。若本次資料沒有傳輸成功 ,、’貝料庫更新模組1 2於本地資料庫2中將本次資料的標 ΗV. Description of the invention (10) The data marked as "0" and its file name, and a new process is restarted; if there is no data marked as "" 〇" in the local database 2, the sharp is local The data to be sent in the database 2 has been sent, and the program is terminated. Please refer to the fifth figure, which is a flowchart of the multi-threaded data sending method of the present invention. ^ Start a thread to set this data and its file name to send: After step sm, the database update module 12 updates this data tag: S104), the thread tracking sub-module 132 immediately starts Ηττρ will The unread data and its data file name are transmitted to the remote database server step sm)-. When the remote database server 3 successfully receives this time. Data, the remote private database server state 3 to receive this time The data file name is returned to the local application server as the data transmission status, and the thread tracking sub-module fetches the returned data transmission status g. The data transmission wheel is described by the file name in π 軚There are two situations to indicate it. — The data transmission is successful, the other indicates that the data transmission has failed (step ^ ^. The thread queuing submodule 133 waits for the message of the name ^ ^ material file name issued by the last thread (step sm)) Determine whether to receive it, and step S203). If the thread queuing submodule 133 does not receive the message / =: 7, the process queuing submodule 133 continues to wait for the message of the name fmV broadcast case sent by the last thread ( Step S2 ° 2); If the thread queues the sub-module,-and 133 successfully receives the message, the thread tracking sub-module 132 judges that the data owed is lost (step S2 ° 4). If the data is not successfully transmitted this time "," Shell material database update module 1 2 in the local database 2

ll 第15頁 200529007ll p. 15 200529007

五、發明說明(11) =新為〃 0 W:/ %…,組u 一貝料的檔案名作為訊息通知下一個排 毛出本二人 料庫2的線程訪問本地資料庫2,例如更新=f接本地資 ‘JS20 6 );若本次資料傳輸成 Jm,己等(步 進而完成本次線程傳輪本次資 接執仃步驟S206。 本發明雖以較佳眚# ‘, 』巧社。 ^發明。任何熟悉揭露如,然其並非用以限 圍"見後附之申請專利挪,ϋ此本發明之保護範 摩已圍所界定考為準。V. Description of the invention (11) = new 〃 0 W: /% ..., the file name of the group u is used as a message to notify the next thread of the two people's library 2 to access the local database 2, such as update = f access to local resources' JS20 6); if this data transmission is Jm, etc. (stepping to complete the thread transfer this time, the data transfer execution step S206. Although the present invention is better with ##, ^ Invention. Any familiar disclosure such as, but it is not intended to limit the scope of the "applicable patents" attached, so the protection of the present invention has been defined within the scope of the test.

第16頁 200529007 圖式簡單說明 【圖式簡要說明】 第一圖係本發明多線程發送資料系統之硬體架構圖。 第二圖係本發明多線程發送資料系統之本地應用伺服器之 軟體功能模組圖。 第三圖係本發明多線程發送資料系統之多線程運行機制示 意圖。 第四圖係本發明多線程發送資料方法之主應用程式作業流 程圖。 第五圖係為本發明多線程發送資料方法之各個線程傳輸資 料之作業流程圖。 【主要元件說明】 本地應用伺服器 1 資料讀取模組 11 資料庫更新模組 12 線程運行模組 13 線程啟動子模組 131 線程跟蹤子模組 132 線程排隊子模組 133 線程通知子模組 134 本地資料庫 2 遠程資料庫伺服器 3 連接 4 網路 5Page 16 200529007 Brief description of the diagram [Brief description of the diagram] The first diagram is a hardware architecture diagram of the multi-threaded data transmission system of the present invention. The second figure is a software function module diagram of the local application server of the multi-threaded data transmission system of the present invention. The third figure is a schematic diagram of the multi-threaded operation mechanism of the multi-threaded data transmission system of the present invention. The fourth figure is a main application program flow chart of the multi-threaded data sending method of the present invention. The fifth figure is a flow chart of each thread transmitting data in the multi-thread data sending method of the present invention. [Description of main components] Local application server 1 Data reading module 11 Database update module 12 Thread running module 13 Thread starting submodule 131 Thread tracking submodule 132 Thread queuing submodule 133 Thread notification submodule 134 Local database 2 Remote database server 3 Connection 4 Network 5

第17頁Page 17

Claims (1)

200529007 六、申請專利範圍 1. 一種多線程發送資料系統,其可進行資 程發送資料系統包括一本地應用飼服器、t,,,多線 及一遠程資料庫伺服器,其中: 地貧料庫 一本地應用伺服器係用於執行一主應用 數線程進行資料發送,該本地應用伺服^勺卩=啟動複 一資料讀取模組係用於從本地資料二=一 · 檔案名; τ 5貝取資料及其 一線程運行模組係用於為每讀取一筆 線;對:::數資料通道同時傳輸的方式以: 以ίϊ: 中資料傳輸狀態進行跟蹤和記錄, mr?本地資料庫時建立連接的線程進行排 隊並將本=人發送的資料檔案名作為訊息通知下一 隊專待需訪問本地資料庫的線程;及 一資料庫更新模組係用於在本地資料庫中更新已向遠 _程$料庫伺服器發送的資料之標記; 本地貝料庫係用於儲存複數資料及其對應的檔案名以 及資料之標記;及 遠^貝料庫祠服器係用於接收從本地應用伺服器發送 ^來的貝料及其對應的檔案名,並返回該資料的檔案 為資料傳輪狀態至本地應用祠服器。 • 明專利範圍第1項所述之多線程發送資料系統,所 2之線程運行模組還包括一線程啟動子模組,該線程啟 子模、、且係用於為所述之資料讀取模組每讀取一筆資料 p啟動一個線程,並將本次讀取的資料及其檔案名和上 麵 薩 第18頁 200529007 六、申請專利範圍 次資料槽案名提交給該線程。 3 ·如申睛專利範圍第1項所述之多線程發送資料系統,所 述之線程運行模組還包括一線程跟縱子模組,該線程跟 縱子模組係用於啟動HTTP將已提交給所述之線程的資料 及其棺案名傳輸至遠程資料庫伺服器,對所述之線程中 的資料傳輸狀態進行跟蹤,並接收從遠程資料庫伺服器 返回的資料傳輪狀態之訊息。 4 ·如申請專利範圍第1項所述之多線程發送資料系統,所 述之線程運行模組還包括一線程排隊子模組,該線程排 隊子模組係用於當複數線程訪問本地資料庫時需建立連 接的線程進行排隊。 •士申明專利範圍第1項所述之多線程發送資料系統,所 述之線程運行模組還包括一線程通知子模組,該線程通 知子板組係用於發出本次已發送的資料檔案名作為訊息 通知其他排隊等待的線程逕行訪問本地資料庫。 6 ·如申請專利範圍第丨項所述之多線程發送資料系統,所 述之複數資料通道的傳輸方式係指同時啟動複數線程並 行傳輸多筆資料的傳輸方式。 7. 了種多線=發送資料方法’其可藉由一本地應用伺服器 :一本地資料庫及一遠程資料庫伺服器進行資料發送, 該多線程發送資料方法包括如下步驟: 本地應用伺服器啟動一主應用程式; 主應用程式於本地資料庫中讀取一筆需發送的資料及盆 對應的播案名’稱謂本次資料及其檔案名; 八200529007 VI. Scope of patent application 1. A multi-threaded data transmission system, which can perform data transmission. The data transmission system includes a local application feeder, t, multi-line, and a remote database server, of which: The library one local application server is used to execute a main application thread to send data. The local application server ^ spoon 卩 = activates the first data read module is used to retrieve data from the local data two = one · file name; τ 5 The fetching data and one thread operation module are used to read a line for each time; the data transmission mode of the ::: data channel is tracked and recorded with the data transmission status of ϊ :: mr? The thread that establishes the connection queues and uses the data file name sent by this person as a message to inform the next team of threads waiting to access the local database; and a database update module is used to update the local database in the local database. Marking of the data sent by the Yuan_Cheng database server; The local shell database is used to store plural data and their corresponding file names and data tags; and Yuan ^ Bay database SERVER system for receiving transmitted to the shell material and ^ corresponding to the file name from the local application server, and returns the data file for data transfer to the local application state temple wheel SERVER. • The multi-threaded sending data system described in item 1 of the patent scope, the thread running module of 2 also includes a thread starting sub-module, which is used to read the data. Each time the module reads a piece of data, p starts a thread, and submits the data read this time, its file name, and the name of the above file on the 18th page. 3 · The multi-threaded sending data system described in item 1 of Shenyan's patent scope, the thread running module further includes a thread and vertical sub-module, which is used to start HTTP The data submitted to the thread and its case name are transmitted to the remote database server, the data transmission status in the thread is tracked, and the information of the data transfer status returned from the remote database server is received . 4 · The multi-threaded sending data system described in item 1 of the scope of the patent application, the thread running module further includes a thread queuing sub-module, which is used when a plurality of threads access the local database Threads that need to establish a connection are queued. • The multi-threaded sending data system described in Item 1 of the patent scope, the thread running module also includes a thread notification sub-module, which is used to send the sent data file. The name is used as a message to inform other queued threads to access the local database. 6 · According to the multi-threaded data transmission system described in item 丨 of the patent application scope, the transmission method of the plural data channel refers to a transmission method in which plural threads are simultaneously started to transmit multiple data in parallel. 7. A multi-line = data sending method is used to send data through a local application server: a local database and a remote database server. The multi-threaded data sending method includes the following steps: Local application server Start a main application; the main application reads a piece of data to be sent and the corresponding podcast name in the local database, which is the title of this data and its file name; eight 200529007200529007 主應用粒式為讀取的資料 ,並將讀取的本次資料 名提交給本次線程; 啟動一個線程,稱謂本次線程 及其槽案名以及上次資料槽案 本次線程將本次資料及 主應用程式於線程本地 之標記; 其槽案名置於發送狀態; 資料庫中更新已發送的本次 資料 主應用程式連續讀取多筆資料,並為讀取的每一筆資料 啟動一個新的線程; 、 本次線程啟動HTTP傳輸本次資料及其檔案名至遠程資料 庫伺服器; ' 對各個線程在傳輸資料時進行跟蹤與記錄,並在複數線 私之間採用訊息通知其他線程訪問本地資料庫; 當本次線程傳輸本次資料完畢,主應用程式釋放本次線 程所佔用的資源;及 判斷需發送的資料是否發送完畢。 8 ·如申請專利範圍第7項所述之多線程發送資料方法,所 述之判斷需發送的資料是否發送完畢還包括步驟:若需 發送之資料還未發送完畢,則主應用程式循環讀取下一 筆需發送之資料,並重新啟動一個新的線程繼續發送該 資料至遠程資料庫伺服器,直到需發送的資料發送完畢 為止。 9·如申請專利範圍第8項所述之多線程發送資料方法,所 述之主應用程式循環讀取需發送之資料並重新啟動線程 還包括步驟:主應用程式需等待一段時間於本地資料庫The main application granularity is the data to be read, and the name of the read data is submitted to the thread; a thread is started, which is called the name of the current thread and its slot case, and the last data slot case. The data and the main application are marked locally in the thread; the slot case name is placed in the sending state; the database is updated to send the current data. The main application reads multiple pieces of data continuously and starts one for each piece of data read. New thread; 1. This thread starts HTTP to transmit this data and its file name to the remote database server; 'Track and record each thread while transmitting data, and use messages to inform other threads between multiple lines and private Access the local database; When the current thread finishes transmitting the data, the main application releases the resources occupied by the thread; and determines whether the data to be sent has been sent. 8 · According to the multi-threaded data sending method described in item 7 of the scope of the patent application, the method for determining whether the data to be sent has been sent further includes the steps: if the data to be sent has not been sent, the main application program reads it cyclically The next data to be sent, and restart a new thread to continue sending the data to the remote database server until the data to be sent has been sent. 9 · According to the multi-threaded data sending method described in item 8 of the scope of the patent application, the main application program cyclically reads the data to be sent and restarts the thread. The method further includes steps: the main application program needs to wait for a period of time in the local database 第20頁 _ I 200529007 六、申請專利範圍 中讀取需發送的資料。 1 〇·如申請專利範圍第7項所述之多 11 述之本次資料樓案名係用於為ϋ?方法,所 可以訪問本地資料庫之訊息,知下-個 向本地應用伺服器返回的本次:二二::伺:器 述上次資料槽案名係用於所述之上次^貝m所 程訪問本地資料庫之訊息。 ^夭本-人線 申”利範圍第7項戶:述之多線程 述之本地應用伺服器有且只有執行一次主+方^所 循環啟動複數線程傳輸複數資料。王工一 13.如申請專利範圍第7項所述之多線程發送資料方法, 述之對各個線程在啟動HTTp傳輸資 鉾,* 2 荆貝料4進仃跟蹤與記 錄,並在複數線程之間採用訊息通知 地資料庫還包括步驟: 、他線私d問本 本次線程啟動HTTP傳輸本次資料及其檔案名至 料庫伺服器; ^ 4 S 返回一資料傳輸狀態至本地應用伺服器; 接收該返回的資料傳輸狀態; 等待上次線程發出的訊息; 判斷是否收到該訊息; 若成功收到該訊息’則將上述返回的資料傳輸狀態記 錄於本地資料庫中;及 本次線程發出訊息通知下一個排隊等待需連接本地資Page 20 _ I 200529007 VI. The scope of patent application read the information to be sent. 1 〇 · As mentioned in item 7 of the scope of the patent application, the name of this data building as described in item 11 is used as a method to access the information in the local database, knowing the next-return to the local application server This time: 22 :: Serving: Device description The last data slot case name is used to access the local database when the last time mentioned. ^ 夭 本-人 线 申 "profit scope item 7: The multi-threaded local application server has one and only one execution of the main + side ^ The cycle starts multiple threads to transmit multiple data. Wang Gongyi 13. If applied The multi-threaded data sending method described in item 7 of the patent scope, which describes how to start HTTp transmission of data for each thread. * 2 Jingbei 4 tracks and records, and uses a data notification database among multiple threads. It also includes the steps as follows: 1. The thread asks the current thread to initiate HTTP to transmit the data and its file name to the database server; ^ 4 S returns a data transmission status to the local application server; receives the returned data transmission Status; waiting for the message sent by the last thread; judging whether the message was received; if the message was successfully received, the above-mentioned returned data transmission status is recorded in the local database; and the thread sends a message to notify the next queue waiting Need to connect local resources 200529007200529007 六、申請專利範圍 料庫的線程訪問本地資料庫。 1 4.如申請專利範圍第1 3項所述之多線程發送資料之各個 線程傳輸資料方法,所述之判斷是否收到該訊息還包 括步驟:若沒有收到該訊息,則所述之本次線程繼續 等待該訊息。 1 5.如申請專利範圍第丨3項所述之多線程發送資料之各個 線程傳輸資料方法,所述之返回的資料傳輸狀態係指 本次線程發送的本次資料檔案名。 1 6 ·如申請專利範圍第1 3項戶斤述之多線程發送資料之各個 線程間傳輪資料方法,所述之上次線程發出的訊息係 指上次線程發送的上次資料檔案名,所述之本次線程 發出的矾息係指本次線糕發送的本次資料檔案名。6. Scope of patent application The threads of the material library access the local database. 14. According to the method for transmitting data by each thread of the multi-thread sending data described in item 13 of the scope of the patent application, the method for determining whether to receive the message further includes the step of: if the message is not received, then the original The secondary thread continues to wait for the message. 1 5. According to the method for transmitting data by each thread of the multi-thread sending data described in the scope of the patent application, the returned data transmission status refers to the name of the current data file sent by this thread. 16 · According to the method of transmitting data between threads by multi-thread sending data described in item 13 of the scope of the patent application, the message sent by the last thread refers to the last data file name sent by the last thread. The alum information sent by this thread refers to the name of the data file sent by this thread cake. 第22頁Page 22
TW93104245A 2004-02-20 2004-02-20 System and method for sending data by multithread TW200529007A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW93104245A TW200529007A (en) 2004-02-20 2004-02-20 System and method for sending data by multithread

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW93104245A TW200529007A (en) 2004-02-20 2004-02-20 System and method for sending data by multithread

Publications (1)

Publication Number Publication Date
TW200529007A true TW200529007A (en) 2005-09-01

Family

ID=52348305

Family Applications (1)

Application Number Title Priority Date Filing Date
TW93104245A TW200529007A (en) 2004-02-20 2004-02-20 System and method for sending data by multithread

Country Status (1)

Country Link
TW (1) TW200529007A (en)

Similar Documents

Publication Publication Date Title
US20210075876A1 (en) Push notification delivery system
US7707513B2 (en) System for streaming data from server to multiple slave browser windows in client computer through a master browser window
KR100243637B1 (en) Computer server system
US8429655B2 (en) System and method for asynchronous processing in page lifecycle
JP4144897B2 (en) Optimal server in common work queue environment
EP2033122B1 (en) Method and system for ensuring consistency over time of data gathered by distinct software applications
AU2017331066A1 (en) Systems and methods for providing messages to multiple subscribers
US20130124601A1 (en) Facilitating the operation of a client/server application while a client is offline or online
TW200900923A (en) Deterministic memory management in a computing environment
CN110377410A (en) Method for scheduling task, system, electronic equipment and computer readable storage medium
JP2002373256A5 (en)
JP6540201B2 (en) Information processing system and information acquisition method
JP2002073576A (en) Batch job control system
US9430293B2 (en) Deterministic real time business application processing in a service-oriented architecture
US6934761B1 (en) User level web server cache control of in-kernel http cache
TWI279673B (en) Method, apparatus and system for stamping an event with a time stamp
CN108733515A (en) Dispatching method, file backup method, device and the storage medium of file backup
EP3069272B1 (en) Managing job status
JP2006004415A (en) Flexible context management for enumerating session using context replacement
JP2001516083A (en) Delivery and queuing of certified messages in multipoint publish / subscribe communications
US8271594B2 (en) Master-slave interactions synchronization using instant messaging
US8863149B2 (en) Message processing apparatus and message processing method
TW200529007A (en) System and method for sending data by multithread
CN108833147B (en) Configuration information updating method and device
GB2547072A (en) Method and system for managing queues