﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-天道酬勤-文章分类-C++</title><link>http://www.cppblog.com/pcyang2008/category/10624.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 21 May 2009 15:34:56 GMT</lastBuildDate><pubDate>Thu, 21 May 2009 15:34:56 GMT</pubDate><ttl>60</ttl><item><title>多线程编程</title><link>http://www.cppblog.com/pcyang2008/articles/83595.html</link><dc:creator>程程</dc:creator><author>程程</author><pubDate>Thu, 21 May 2009 10:48:00 GMT</pubDate><guid>http://www.cppblog.com/pcyang2008/articles/83595.html</guid><wfw:comment>http://www.cppblog.com/pcyang2008/comments/83595.html</wfw:comment><comments>http://www.cppblog.com/pcyang2008/articles/83595.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/pcyang2008/comments/commentRss/83595.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/pcyang2008/services/trackbacks/83595.html</trackback:ping><description><![CDATA[<strong><br>&nbsp;&nbsp;&nbsp;&nbsp;// 创建一个线程 <br>&nbsp;hThread = ::CreateThread (&nbsp;NULL, // 默认安全属性 <br>&nbsp;&nbsp;NULL, // 默认堆栈大小 <br>&nbsp;&nbsp;ThreadProc, // 线程入口地址（执行线程的函数） <br>&nbsp;&nbsp;NULL, // 传给函数的参数 <br>&nbsp;&nbsp;0, // 指定线程立即运行 <br>&nbsp;&nbsp;&amp;dwThreadId); // 返回线程的ID号<br><br>线程同步方法：<br>1临界区:</strong>通过对多线程的串行化来访问公共资源或一段代码，速度快，适合控制数据访问。<br><br><strong>2互斥量:</strong>为协调共同对一个共享资源的单独访问而设计的。<br><br><strong>3信号量:</strong>为控制一个具有有限数量用户资源而设计。<br><br><strong>4事 件:</strong>用来通知线程有一些事件已发生，从而启动后继任务的开始。<br><br>多线程编程注意a，线程之间的执行顺序不可以预知。<br>&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; b：线程之间的切换任意时间，地点发生。<br>&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; c： 线程并不总是立刻就启动。
<img src ="http://www.cppblog.com/pcyang2008/aggbug/83595.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/pcyang2008/" target="_blank">程程</a> 2009-05-21 18:48 <a href="http://www.cppblog.com/pcyang2008/articles/83595.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>