并行与并发
2016-02-29 18:12
435 查看
html, body {
font-size: 15px;
}
body {
font-family: Helvetica, "Hiragino Sans GB", 微软雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif;
line-height: 1.6;
color: ;
background-color: ;
margin: 0;
padding: 16px 20px;
}
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
margin: 1.33rem 0 0.667rem;
padding: 0;
font-weight: bold;
}
h1 {
font-size: 21px;
font-size: 1.4rem;
}
h2 {
font-size: 20px;
font-size: 1.33rem;
}
h3 {
font-size: 18px;
font-size: 1.2rem;
}
h4 {
font-size: 17px;
font-size: 1.13rem;
}
h5 {
font-size: 15px;
font-size: 1rem;
}
h6 {
font-size: 15px;
font-size: 1rem;
color: #777777;
margin: 1rem 0;
}
div, p, ul, ol, dl, li {
margin: 0;
}
blockquote, table, pre, code{
margin: 8px 0;
}
ul, ol {
padding-left: 32px;
padding-left: 2.13rem;
}
blockquote {
border-left: 4px solid #dddddd;
padding: 0 12px;
padding: 0 0.8rem;
}
blockquote > :first-child {
margin-top: 0;
}
blockquote > :last-child {
margin-bottom: 0;
}
img {
border: 0;
max-width: 100%;
height: auto !important;
margin: 2px 0;
}
table {
border-collapse: collapse;
border: 1px solid #bbbbbb;
}
td {
padding:4px 8px;
border-collapse: collapse;
border: 1px solid #bbbbbb;
}
@media screen and (max-width: 660px) {
body {
padding: 20px 18px;
padding: 1.33rem 1.2rem;
}
}
@media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) {
html, body {
font-size: 17px;
}
body {
line-height: 1.7;
padding: 0.75rem 0.9375rem;
color: #353c47;
}
h1 {
font-size: 2.125rem;
}
h2 {
font-size: 1.875rem;
}
h3 {
font-size: 1.625rem;
}
h4 {
font-size: 1.375rem;
}
h5 {
font-size: 1.125rem;
}
h6 {
color: inherit;
}
ul, ol {
padding-left: 2.5rem;
}
blockquote {
padding: 0 0.9375rem;
}
}
并行与并发
时间:2015年12月25日14:32:24
![](http://images2015.cnblogs.com/blog/900264/201602/900264-20160229181146908-1175162794.png)
直观来讲,并发是两个等待队列中的人同时去竞争一台咖啡机(当然,人是有理性懂礼貌的动物(也不排除某些很霸道的人插队的可能),两队列中的排队者也可能约定交替使用咖啡机,也可能是大家同时竞争咖啡机,谁先竞争到咖啡机谁使用,不过后一种的方法可能引发冲突,因为两个队列里面排在队列首位的人可能同时使用咖啡机),每个等待者在使用咖啡机之前不仅需要知道排在他前面那个人是否已经使用完了咖啡机,还需知道另一个队列中排在首位的人是否也正准备使用咖啡机;而并行是每个队列拥有自己的咖啡机,两个队列之间并没有竞争的关系,队列中的某个排队者只需等待队列前面的人使用完咖啡机,然后再轮到自己使用咖啡机。
因此,并发意味着多个执行实体(比方说上面例子中的人)可能需要竞争资源(咖啡机),因此就不可避免带来竞争和同步的问题;而并行则是不同的执行实体拥有各自的资源,相互之间可能互不干扰。
Concurrency: Programming as the composition of independently executing processes.
Parallelism: Programming as the simultaneous execution of (possibly related) computations.
来自为知笔记(Wiz)
font-size: 15px;
}
body {
font-family: Helvetica, "Hiragino Sans GB", 微软雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif;
line-height: 1.6;
color: ;
background-color: ;
margin: 0;
padding: 16px 20px;
}
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
margin: 1.33rem 0 0.667rem;
padding: 0;
font-weight: bold;
}
h1 {
font-size: 21px;
font-size: 1.4rem;
}
h2 {
font-size: 20px;
font-size: 1.33rem;
}
h3 {
font-size: 18px;
font-size: 1.2rem;
}
h4 {
font-size: 17px;
font-size: 1.13rem;
}
h5 {
font-size: 15px;
font-size: 1rem;
}
h6 {
font-size: 15px;
font-size: 1rem;
color: #777777;
margin: 1rem 0;
}
div, p, ul, ol, dl, li {
margin: 0;
}
blockquote, table, pre, code{
margin: 8px 0;
}
ul, ol {
padding-left: 32px;
padding-left: 2.13rem;
}
blockquote {
border-left: 4px solid #dddddd;
padding: 0 12px;
padding: 0 0.8rem;
}
blockquote > :first-child {
margin-top: 0;
}
blockquote > :last-child {
margin-bottom: 0;
}
img {
border: 0;
max-width: 100%;
height: auto !important;
margin: 2px 0;
}
table {
border-collapse: collapse;
border: 1px solid #bbbbbb;
}
td {
padding:4px 8px;
border-collapse: collapse;
border: 1px solid #bbbbbb;
}
@media screen and (max-width: 660px) {
body {
padding: 20px 18px;
padding: 1.33rem 1.2rem;
}
}
@media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) {
html, body {
font-size: 17px;
}
body {
line-height: 1.7;
padding: 0.75rem 0.9375rem;
color: #353c47;
}
h1 {
font-size: 2.125rem;
}
h2 {
font-size: 1.875rem;
}
h3 {
font-size: 1.625rem;
}
h4 {
font-size: 1.375rem;
}
h5 {
font-size: 1.125rem;
}
h6 {
color: inherit;
}
ul, ol {
padding-left: 2.5rem;
}
blockquote {
padding: 0 0.9375rem;
}
}
并行与并发
时间:2015年12月25日14:32:24
![](http://images2015.cnblogs.com/blog/900264/201602/900264-20160229181146908-1175162794.png)
直观来讲,并发是两个等待队列中的人同时去竞争一台咖啡机(当然,人是有理性懂礼貌的动物(也不排除某些很霸道的人插队的可能),两队列中的排队者也可能约定交替使用咖啡机,也可能是大家同时竞争咖啡机,谁先竞争到咖啡机谁使用,不过后一种的方法可能引发冲突,因为两个队列里面排在队列首位的人可能同时使用咖啡机),每个等待者在使用咖啡机之前不仅需要知道排在他前面那个人是否已经使用完了咖啡机,还需知道另一个队列中排在首位的人是否也正准备使用咖啡机;而并行是每个队列拥有自己的咖啡机,两个队列之间并没有竞争的关系,队列中的某个排队者只需等待队列前面的人使用完咖啡机,然后再轮到自己使用咖啡机。
因此,并发意味着多个执行实体(比方说上面例子中的人)可能需要竞争资源(咖啡机),因此就不可避免带来竞争和同步的问题;而并行则是不同的执行实体拥有各自的资源,相互之间可能互不干扰。
Concurrency: Programming as the composition of independently executing processes.
Parallelism: Programming as the simultaneous execution of (possibly related) computations.
来自为知笔记(Wiz)
相关文章推荐
- 代码的重构
- ORA-00604 ORA-14452 ORA-20783
- 干到起皮的货丨这些年,我们追过的 fiddler
- QT TTS朗读
- Git 常用命令详解
- web页面取用户控件页面中服务器控件的值
- 课程引言课后作业1
- 线程安全与线程不安全
- 软件测试
- 四道Java基础题
- android setVolumeControlStream多媒体音量控制介绍
- maven 学习
- 数据库安全模式 日志文件多工 控制文件多工 归档模式
- php curl破解图片防盗链
- HDU 1022 Train Problem I(stack)
- AngularJS的路由、模块、依赖注入
- 四年才有的今天总觉得应该做点啥
- 透明度
- MySQL 5.6 my.cnf 模版
- Java不变类