﻿<?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++博客-zoyizhang-随笔分类-技术杂文</title><link>http://www.cppblog.com/zoyi-zhang/category/9630.html</link><description>种瓜得瓜~~~种豆得豆</description><language>zh-cn</language><lastBuildDate>Fri, 18 Jun 2010 17:05:00 GMT</lastBuildDate><pubDate>Fri, 18 Jun 2010 17:05:00 GMT</pubDate><ttl>60</ttl><item><title>【转载】同步和异步（通俗易懂）</title><link>http://www.cppblog.com/zoyi-zhang/archive/2010/06/17/118080.html</link><dc:creator>zoyi</dc:creator><author>zoyi</author><pubDate>Thu, 17 Jun 2010 06:40:00 GMT</pubDate><guid>http://www.cppblog.com/zoyi-zhang/archive/2010/06/17/118080.html</guid><wfw:comment>http://www.cppblog.com/zoyi-zhang/comments/118080.html</wfw:comment><comments>http://www.cppblog.com/zoyi-zhang/archive/2010/06/17/118080.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zoyi-zhang/comments/commentRss/118080.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zoyi-zhang/services/trackbacks/118080.html</trackback:ping><description><![CDATA[<h3><a href="http://www.cppblog.com/blog/151724"><u><font color=#0066cc>同步和异步</font></u></a></h3>
关键字: 同步 异步
<div class=blog_content>同步在一定程度上可以看做是单线程，这个线程请求一个方法后就待这个方法给他回复，否则他不往下执行(死心眼)。 <br><br>异步在一定程度上可以看做是多线程的(废话，一个线程怎么叫异步)，请求一个方法后，就不管了，继续执行其他的方法。 <br><br>比如一个文章系统里面，文章内容通常是字数非常多的，如果数据量大，打开会非常的慢，这个时候可以采取两种方法： <br><br>1、死心眼：一直等待要显示的数据全部取出来 <br><br>标题、作者、来源、创建时间、关键字、点击次数、文章正文&nbsp; <br><br>ok，全部取出 <br><br>显示 <br><br>碰上心急的用户，他会骂死你的。 <br><br>2、异步：首先显示能够快速取出的部分： <br><br>标题、作者、来源、创建时间、关键字、点击数 <br><br>显示 <br><br>然后另外的一个线程等待取出文章的正文显示！ <br><br>异步就是：做一件事情的同事，不影响做其他的事情。 <br><br>----------------------------------------- <br>转帖一些文字： <br><br>所谓同步，可以理解为在执行完一个函数或方法之后，一直等待系统返回值或消息，这时程序是出于阻塞的，只有接收到返回的值或消息后才往下执行其他的命令。&nbsp; <br>&nbsp;&nbsp; <br>异步，执行完函数或方法后，不必阻塞性地等待返回值或消息，只需要向系统委托一个异步过程，那么当系统接收到返回值或消息时，系统会自动触发委托的异步过程，从而完成一个完整的流程。&nbsp; <br>&nbsp;&nbsp; <br>并不是说谁好谁不好，只是同步的机制不适合在正式应用的项目当中（但自己测试还是可以的） <br><br>同步，就是实时处理，比如服务器一接收客户端请求，马上响应，这样客户端可以在最短的时间内得到结果，但是如果多个客户端，或者一个客户端发出的请求很频繁，服务器无法同步处理，就会造成涌塞。&nbsp; <br><br>异步，就是分时处理，服务器接收到客户端请求后并不是立即处理，而是等待服务器比较空闲的时候加以处理，可以避免涌塞。&nbsp; <br><br>同步和异步之分： <br>同步就是调用一个函数，直接函数执行完了才返回到调用函数 <br>异步就是被调用函数初始化完后马上返回。 <br><br>---------- <br>同步就是(我死心眼)我等你(给我回答)，异步就是(我很忙)我不等你(给我回答) <br><br>严格的说，异步还是有两种 <br>一种是等，但是等的过程和同步不一样，等的时候可以做别的工作，但是程序的主线还是等待&nbsp; WaitforSingleObject(hEvent,INFINTE,TRUE);&nbsp; <br><br>另外一种是CALLBACK方式，这种异步是完全不等待，程序主线发出请求之后就干别的事情去了，完全不理会请求执行的如何。&nbsp; <br><br>所有异步必然设计两个以上的线程（不然不存在异步的问题），第一种方式下，请求的后期工作是在发出请求的线程上执行，第二种方式下，后期工作可以在任何线程（通常是执行请求的线程上）完成。 </div>
<img src ="http://www.cppblog.com/zoyi-zhang/aggbug/118080.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zoyi-zhang/" target="_blank">zoyi</a> 2010-06-17 14:40 <a href="http://www.cppblog.com/zoyi-zhang/archive/2010/06/17/118080.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>The Evolution of the SQL Server DBA&lt;翻译~~还没翻译完~~休息一会~~&gt;</title><link>http://www.cppblog.com/zoyi-zhang/archive/2009/02/22/74574.html</link><dc:creator>zoyi</dc:creator><author>zoyi</author><pubDate>Sun, 22 Feb 2009 07:11:00 GMT</pubDate><guid>http://www.cppblog.com/zoyi-zhang/archive/2009/02/22/74574.html</guid><wfw:comment>http://www.cppblog.com/zoyi-zhang/comments/74574.html</wfw:comment><comments>http://www.cppblog.com/zoyi-zhang/archive/2009/02/22/74574.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zoyi-zhang/comments/commentRss/74574.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zoyi-zhang/services/trackbacks/74574.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/zoyi-zhang/archive/2009/02/22/74574.html'>阅读全文</a><img src ="http://www.cppblog.com/zoyi-zhang/aggbug/74574.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zoyi-zhang/" target="_blank">zoyi</a> 2009-02-22 15:11 <a href="http://www.cppblog.com/zoyi-zhang/archive/2009/02/22/74574.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Microsoft tells its security story (in pictures)（translation）</title><link>http://www.cppblog.com/zoyi-zhang/archive/2009/02/20/74364.html</link><dc:creator>zoyi</dc:creator><author>zoyi</author><pubDate>Fri, 20 Feb 2009 01:48:00 GMT</pubDate><guid>http://www.cppblog.com/zoyi-zhang/archive/2009/02/20/74364.html</guid><wfw:comment>http://www.cppblog.com/zoyi-zhang/comments/74364.html</wfw:comment><comments>http://www.cppblog.com/zoyi-zhang/archive/2009/02/20/74364.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/zoyi-zhang/comments/commentRss/74364.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/zoyi-zhang/services/trackbacks/74364.html</trackback:ping><description><![CDATA[原文：<br>
It's been a long strange trip toward better security for Microsoft, but
they've made enough progress to have both improvements to their
technique and some highly interesting war stories. The company's got a
new site explaining the past decade's advances, and you have a reson to
read comics at work day. <br>
<br>
The process of "baking security in" -- getting developers to think
about security less as "those people who yell at us" and more as an
integral part of any software-construction effort -- lends its name to
Baking Security In. which details Microsoft's progress on the Sccurity
Development Lifecycle, a process involving 14 stages and checkpoints
over the six stages of the software-devlopment cycle (requirments,
design, implement, verification, release, support/service ).<br>
<br>
Microsoft has previously estimated that adoption of the SDL strategy
increases lifecycle costs by 20%, If that's a hit the company's willing
to take to build security into their products, building a fairly clever
educational site including "The Amaing Adeventures of Kevlarr", a
developer who requires some convincing (that's him above), is just part
of the effort, But come forthe comics and stay for the videos, as
real-life, non-animated Microsofties like Steve Lipner and Michael
Howard recount their memories of the days before Microsoft got
security-serious.<br>
<br>
<br>
译文：<br>
微软安全开发的旅程奇怪而又漫长，但是他们在技术的进步和有趣的战略故事上都发展迅速，微软今天启动了一个新站点用动画的形式来解释过去十年中微软就安全技术方面所作出的努力和进步，很值得在上班的时候看一看这个连环画。<br>
<br>
&#8220;baking sercurity in&#8221;
这个过程，是让开发者不仅仅是考虑那些侵犯系统程序的人，而且要更多将安全作为任何一个软件开发努力中完整的一部分，将这个过程取名为&#8220;Baking
Security in&#8221;,
在这个连环画中详细介绍了微软在安全开发周期(SDL)中的进步，其中包括14个阶段和检查要点覆盖了软件开发周期的六个步骤（需求，设计，实施，验证，
发表，支持/服务）。<br>
<br>
微软先前估计如果采用SDL战略成本将增加20%，但是如果这是必要的，那么公司愿意去为其产品建立安全体系，并且建立一个很有教育意义的网站包含
&#8220;Kevlarr的传奇经历&#8221;，一个开发者很有说服力，其为安全开发周期做出了努力。但是他来自动画，停留在视频上，而作为现实中非动画虚构的人物像
Steve Lipner和Michael Howard回忆了在微软有意识安全问题严重性以前的那段日子。<br>
<br>  <img src ="http://www.cppblog.com/zoyi-zhang/aggbug/74364.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/zoyi-zhang/" target="_blank">zoyi</a> 2009-02-20 09:48 <a href="http://www.cppblog.com/zoyi-zhang/archive/2009/02/20/74364.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>