亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tut15.html

?? WINDOWS程序員使用指南--匯編基礎(chǔ)
?? HTML
?? 第 1 頁 / 共 3 頁
字號:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Iczelion">
   <meta name="GENERATOR" content="Mozilla/4.51 [en] (Win95; I) [Netscape]">
   <title>Iczelion's Win32 Assembly Tutorial 15: Multithreading Programming</title>
</head>
<body text="#FFFFFF" bgcolor="#000080" link="#FFFF00" vlink="#8080FF" alink="#FF00FF">

<center>
<h1>
<font face="Arial,Helvetica"><font color="#FFFFCC"><font size=+2>Tutorial
15: Multithreading Programming</font></font></font></h1></center>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>We will
learn how to create a multithreading program in this tutorial. We also
study the communication methods between the threads.</font></font></font><font face="Arial,Helvetica"><font size=-1></font></font>
<p><font face="Arial,Helvetica"><font size=-1><font color="#FFFFFF">Download
the example </font><font color="#000000"><a href="files/tut15.zip">here</a>.</font></font></font>
<h3>
<font face="Arial,Helvetica"><font color="#33FF33"><font size=+0>Theory:</font></font></font></h3>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>In previous
tutorial, you learn the a process consists of at least one thread: the
primary thread. A thread is a chain of execution. You can also create additional
threads in your program. You can view multithreading as multitasking within
one program. In term of implementation, a thread is a function that runs
concurrently with the main program. You can run several instances of the
same function or you can run several functions simultaneously depending
on your requirement. Multithreading is specific to Win32, no Win16 counterpart
exists.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Threads
run in the same process so they can access any resources in the process
such as global variables, handles etc. However, each thread has its own
stack so local variables in each thread are private. Each thread also owns
its private register set so when Windows switches to other threads, the
thread can "remember" its last status and can "resume" the task when it
gains control again. This is handled internally by Windows.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>We
can divide threads into two caterories:</font></font></font>
<ol>
<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>User interface
thread: This type of thread creates its own window so it receives windows
messages. It can respond to the user via its own window hence the name.
This type of thread is subject to Win16 Mutex rule which allows only one
user interface thread in 16-bit user and gdi kernel. While a user interface
thread is executing code in 16-bit user and gdi kernel, other UI threads
cannot use the service of the 16-bit user and gdi kernel. Note that this
Win16 Mutex is specific to Windows 95 since underneath, Windows 95 API
functions thunk down to 16-bit code. Windows NT has no Win16 Mutex so the
user interface threads under NT work more smoothly than under Windows 95.</font></font></font></li>

<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Worker
thread: This type of thread does not create a window so it cannot receive
any windows message. It exists primarily to do the assigned job in the
background hence the name worker thread.</font></font></font></li>
</ol>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>I advise
the following strategy when using multithreading capability of Win32: Let
the primary thread do user interface stuff and the other threads do the
hard work in the background. In this way, the primary thread is like a
Governor, other threads are like the Governor's staff. The Governor delegates
jobs to his staff while he maintains contact with the public. The Governor
staff obediently performs the work and reports back to the Governor. If
the Governor were to perform every task himself, he would not be able to
give much attention to the public or the press. That's akin to a window
which is busy doing a lengthy job in its primary thread: it doesn't respond
to the user until the job is completed. Such a program can benefit from
creating an additonal thread which is responsible for the lengthy job,
allowing the primary thread to respond to the user's commands.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>We
can create a thread by calling CreateThread function which has the following
syntax:</font></font></font><font face="Arial,Helvetica"><font size=-1></font></font>
<p><b><font face="Arial,Helvetica"><font color="#FFFFCC"><font size=-1>CreateThread
proto lpThreadAttributes:DWORD,\</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#FFFFCC"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
dwStackSize:DWORD,\</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font size=-1><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font><font color="#FFFFCC">lpStartAddress:DWORD,\</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#FFFFCC"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
lpParameter:DWORD,\</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font color="#FFFFCC"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
dwCreationFlags:DWORD,\</font></font></font></b>
<br><b><font face="Arial,Helvetica"><font size=-1><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font><font color="#FFFFCC">lpThreadId:DWORD</font></font></font></b><font face="Arial,Helvetica"><font size=-1></font></font>
<p><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>CreateThread
function looks a lot like CreateProcess.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#009900">lpThreadAttributes</font></b><font color="#FFFFFF">&nbsp;
--> You can use NULL if you want the thread to have default security descriptor.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#009900">dwStackSize</font></b><font color="#000000">

</font><font color="#FFFFFF">--> specify the stack size of the thread.
If you want the thread to have the same stack size as the primary thread,
use NULL as this parameter.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#009900">lpStartAddress</font></b><font color="#FFFFFF">-->
Address of the thread function.It's the function that will perform the
work of the thread. This function MUST receive one and only one 32-bit
parameter and return a 32-bit value.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#009900">lpParameter</font></b><font color="#000000">&nbsp;</font><font color="#FFFFFF">
--> The parameter you want to pass to the thread function.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#009900">dwCreationFlags</font></b><font color="#FFFFFF">
--> 0 means the thread runs immediately after it's created. The opposite
is CREATE_SUSPENDED flag.</font></font></font>
<br><font face="Arial,Helvetica"><font size=-1><b><font color="#009900">lpThreadId</font></b><font color="#000000">

</font><font color="#FFFFFF">--> CreateThread function will fill the thread
ID of the newly created thread at this address.</font></font></font><font face="Arial,Helvetica"><font size=-1></font></font>
<p><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>If
CreateThread call is sucessful, it returns the handle of the newly created
thread. Otherwise, it returns NULL.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>The
thread function runs as soon as CreateThread call is success ful unless
you specify CREATE_SUSPENDED flag in dwCreationFlags. In that case, the
thread is suspended until ResumeThread function is called.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>When
the thread function returns with ret instruction, Windows calls ExitThread
function for the thread function implicitly. You can call ExitThread function
with in your thread function yourself but there' s little point in doing
so.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>You
can retrieve the exit code of a thread by calling GetExitCodeThread function.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>If
you want to terminate a thread from other thread, you can call TerminateThread
function. But you should use this function under extreme circumstance since
this function terminates the thread immediately without giving the thread
any chance to clean up after itself.</font></font></font><font face="Arial,Helvetica"><font size=-1></font></font>
<p><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Now
let's move to the communication methods between threads.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>There
are three of them:</font></font></font>
<ul>
<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Using
global variables</font></font></font></li>

<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Windows
messages</font></font></font></li>

<li>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Event</font></font></font></li>
</ul>
<font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Threads
share the process's resources including global variables so the threads
can use global varibles to communicate with each other. However this method
must be used with care. Thread synchronization must enter into consideration.
For example, if two threads use the same structure of 10 members , what
happens when Windows suddenly yanks the control from one of the thread
when it was in the middle of updating the structure? The other thread will
be left with an inconsistent data in the structure! Don't make any mistake,
multithreading programs are harder to debug and maintain. This sort of
bug seems to happen at random which is very hard to track down.</font></font></font>
<br><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>You
can also use Windows messages to communicate between threads. If the threads
are all user interface ones, there's no problem: this method can be used
as a two-way communication. All you have to do is defining one or more
custom windows messages that are meaningful to the threads. You define
a custom message by using WM_USER message as the base value say , you can
define it like this:</font></font></font><font face="Arial,Helvetica"><font size=-1></font></font>
<p><font face="Arial,Helvetica"><font color="#FFFFCC"><font size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
WM_MYCUSTOMMSG equ WM_USER+100h</font></font></font><font face="Arial,Helvetica"><font size=-1></font></font>
<p><font face="Arial,Helvetica"><font color="#FFFFFF"><font size=-1>Windows

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品美女在线观看| 在线亚洲人成电影网站色www| 国产精品自产自拍| 99久久免费精品| 欧美日韩国产一区| 久久夜色精品国产噜噜av | 国产成人在线免费| 91性感美女视频| 欧美一级日韩免费不卡| 国产精品萝li| 美国十次综合导航| 99re这里只有精品视频首页| 欧美一区二区福利在线| 国产精品亲子伦对白| 日韩电影一二三区| www.欧美色图| 精品日韩在线观看| 亚洲国产综合在线| 国产成人自拍高清视频在线免费播放| 在线观看一区二区视频| 久久久久久亚洲综合影院红桃 | 91精品午夜视频| 国产精品麻豆一区二区| 老鸭窝一区二区久久精品| 99re在线视频这里只有精品| 欧美大度的电影原声| 一区二区三区**美女毛片| 国产乱码一区二区三区| 欧美日韩aaaaaa| 亚洲人成伊人成综合网小说| 激情国产一区二区| 欧美色爱综合网| 国产精品进线69影院| 精品一区在线看| 欧美日韩一区二区三区在线看| 欧美高清在线一区二区| 美女一区二区三区| 欧美日韩一区二区在线视频| 国产精品乱码人人做人人爱 | 久久久久久电影| 五月激情六月综合| 91蜜桃在线观看| 中文字幕欧美三区| 国产精品正在播放| 欧美videos大乳护士334| 视频一区二区三区在线| 欧美主播一区二区三区美女| 国产精品成人一区二区艾草| 成人短视频下载| 欧美白人最猛性xxxxx69交| 亚洲动漫第一页| 色94色欧美sute亚洲线路一ni| 久久久一区二区三区捆绑**| 看电视剧不卡顿的网站| 欧美日韩1区2区| 亚洲成人av中文| 欧美亚洲一区三区| 亚洲精品国产第一综合99久久| 成人av电影免费观看| 国产欧美精品一区| 国产精品99久久不卡二区| 精品国产91久久久久久久妲己| 日本在线观看不卡视频| 欧美久久久久免费| 日本亚洲免费观看| 5月丁香婷婷综合| 日本伊人精品一区二区三区观看方式| 欧美探花视频资源| 午夜视频一区在线观看| 欧美日韩美女一区二区| 亚洲成人av中文| 欧美精品视频www在线观看| 亚洲va欧美va天堂v国产综合| 欧美日韩一级黄| 午夜久久久影院| 欧美精品日韩一区| 日韩福利视频导航| 日韩欧美亚洲一区二区| 国内外成人在线视频| 久久综合九色综合欧美亚洲| 国产电影一区在线| 国产精品美女久久久久久久| 94-欧美-setu| 亚洲一区二区视频在线| 欧美日韩国产成人在线免费| 青青草91视频| 久久精品一区二区三区四区| 国产成人免费视频网站高清观看视频| 国产拍揄自揄精品视频麻豆| 99在线精品一区二区三区| 亚洲人成小说网站色在线 | 视频在线观看一区| 日韩一级欧美一级| 国产一区二区三区电影在线观看 | av在线不卡免费看| 亚洲午夜国产一区99re久久| 88在线观看91蜜桃国自产| 久久精品国产精品亚洲红杏| 久久久久久久久岛国免费| 国产成人h网站| 亚洲另类中文字| 欧美精品丝袜久久久中文字幕| 久久99精品久久只有精品| 国产日韩欧美不卡在线| 欧洲在线/亚洲| 蜜臀久久99精品久久久久宅男| 2024国产精品| 日本国产一区二区| 麻豆精品在线看| 一区在线观看免费| 在线不卡a资源高清| 国产成人免费视频网站| 亚洲第一会所有码转帖| 337p日本欧洲亚洲大胆色噜噜| 99视频精品在线| 日韩黄色免费网站| 欧美激情一区二区三区四区| 欧美色图一区二区三区| 国产在线精品一区二区三区不卡| 日韩理论在线观看| 欧美一区二区成人6969| 91视频在线观看| 激情文学综合丁香| 亚洲综合久久久久| 久久精品水蜜桃av综合天堂| 在线观看视频一区| 国产成人在线色| 日本亚洲最大的色成网站www| 国产精品久久久久久久久久免费看 | 欧美电影免费观看完整版| 91网站最新地址| 国产精品一区二区黑丝| 亚洲一区在线看| 欧美国产精品一区| 欧美一二三区在线| 日本韩国欧美一区| 国产风韵犹存在线视精品| 日本不卡视频在线观看| 亚洲婷婷综合色高清在线| 久久综合久久久久88| 91.麻豆视频| 色欧美片视频在线观看在线视频| 激情综合色丁香一区二区| 亚洲一区二区四区蜜桃| 国产精品久久久久久久久搜平片| 欧美成人激情免费网| 欧美顶级少妇做爰| 色老汉av一区二区三区| 国产乱人伦精品一区二区在线观看| 五月婷婷综合激情| 一区二区三区在线观看视频| 国产精品色哟哟网站| 久久夜色精品一区| 欧美www视频| 91精品免费在线| 欧美性三三影院| 色综合久久天天| 99re这里只有精品首页| 成人午夜免费av| 国产一区二区三区免费观看| 日本亚洲欧美天堂免费| 三级欧美韩日大片在线看| 亚洲一区中文日韩| 伊人一区二区三区| 亚洲人成精品久久久久| 国产精品国产自产拍高清av| 国产午夜精品理论片a级大结局| 精品国产一区二区精华| 日韩午夜av一区| 欧美一区二区三区小说| 91精品国产福利在线观看| 欧美日韩高清在线| 91精品在线一区二区| 欧美一区二区三区啪啪| 宅男噜噜噜66一区二区66| 欧美老女人第四色| 欧美精品一二三| 7777精品伊人久久久大香线蕉的| 欧美亚洲一区二区在线观看| 欧美三日本三级三级在线播放| 日本道色综合久久| 欧美三级中文字幕| 欧美日韩一区二区三区在线| 欧美日韩一级二级三级| 91精品婷婷国产综合久久性色| 欧美久久久久中文字幕| 欧美一区二区三区男人的天堂| 日韩欧美亚洲国产另类| 日韩天堂在线观看| 久久免费视频色| 欧美激情一区二区三区全黄| 国产精品欧美经典| 亚洲欧美一区二区三区久本道91| 亚洲天堂精品在线观看| 亚洲激情图片小说视频| 视频一区欧美精品| 精品无人码麻豆乱码1区2区| 国产成人亚洲精品狼色在线| 91首页免费视频| 欧美精品日日鲁夜夜添|