【正文】
所以我必須得有一個(gè)線程負(fù)責(zé)來(lái)處理這些消息,正如剛才所說(shuō)的應(yīng)該觸發(fā)重畫(huà)屏幕的工作。正如后面的文章所示,我將給出詳細(xì)的編程示例,通過(guò)這些例子,你將可以更好的理解多線程。 如果一個(gè)程序的運(yùn)行有一定的順序,這時(shí)候采用這種方式可能會(huì)出現(xiàn)問(wèn)題,甚至導(dǎo)致整個(gè)程序崩潰。如果沒(méi)有找到同一優(yōu)先級(jí)或更高級(jí)的線程,當(dāng)前線程還繼續(xù)占有 cpu。在處理機(jī)空閑,即該進(jìn)程沒(méi)有使用時(shí) cpu,系統(tǒng)可以允許其他的進(jìn)程暫時(shí)使用 cpu。它同時(shí)他維持著所有的線程和循環(huán) ,分配很少量的 cpu 時(shí)間給線程。線程有時(shí)也被稱為并行運(yùn)行在程序里的輕量級(jí)進(jìn)程 ,線程被稱為是輕量級(jí)進(jìn)程是因?yàn)樗倪\(yùn)行依賴與進(jìn)程提供的上下文環(huán)境 ,并且使用的是進(jìn)程的資源。s input, those responsible for dealing with a very long timeconsuming task. This will make the procedure more flexible and can quickly respond. At the same time, users can also run any time the possibility of the abolition of the task. Drawing graphics in this case, the procedure should always be made to the system responsible for receiving the news. If the procedures are busy on a mission, there may result into a blank screen, which is obviously the need for our procedures to deal with such incidents. So I have to have a thread to deal with these sources is responsible for, as I said earlier should be the trigger of the work of redrawing the screen. We should grasp the principle of timefor those who need to pare the urgency of the task immediately, we are due to the high priority given the other priorities of the threads should be lower than her priority. Client requests listener thread should always be high priority, for a user interaction with the task of the user interface。 each part of the implementation was as a thread. Therefore, in the preparation of applications, we have very good design in order to avoid the implementation of the different threads of mutual interference. Which will help us to design robust procedures, we can make at any time when necessary to add the thread. Thread can be described as a microprocess。 therefore, a large number of threads will reduce the efficiency of system operation. Therefore, if the use of multithreaded, then the multithreaded program must be designed well, otherwise the benefits will be far less than the disadvantages. The use of multithreaded so we must be careful to deal with these threads of the creation, scheduling and work release. There are many ways to design multithreaded applications. As shown in the back of the article, I will give detailed examples of programming, through these examples。它負(fù)責(zé)維護(hù)自己的堆棧 ,這些堆棧用于異常處理 ,優(yōu)先級(jí)調(diào)度和其他一些系統(tǒng)重新恢復(fù)線程執(zhí)行時(shí)需要的信息。每個(gè)線程占用 cpu 的時(shí)間取決于進(jìn)程和操作系統(tǒng)。 Windows 95/NT, UNIX 使用的就是這種線程調(diào)度方式。如果你不確定系統(tǒng)采用的是那種調(diào)度策略,假設(shè)搶占的調(diào)度策略不可用是比較安全的。 需要多線程嗎 ? 我們發(fā)出了一個(gè)打印的命令,要求打印機(jī)進(jìn)行打印任務(wù),假設(shè)這時(shí)候計(jì)算機(jī)停止了響應(yīng)而打印機(jī)還在工作,那豈不是我們的停止手上的事情就等著這慢速