互斥/锁 [英] Mutex/Lock

查看:95
本文介绍了互斥/锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好组,


如果我有以下循环的

,其他功能有机会获得锁定:


while(跑步)

{

锁定本地(互斥锁);

}


如果没有,是否足以改变范围:


而(跑步)

{

{

锁定本地(互斥);

}

}


thanx&手,克里斯

hello group,

is there a chance for other functions to get the lock if i have
following loop:

while (running)
{
Lock local(mutex);
}

if not, is it enough to change scope:

while (running)
{
{
Lock local(mutex);
}
}

thanx & hand, chris

推荐答案

Chris Forone写道:
Chris Forone wrote:

hello group,


其他功能有机会获得锁定如果我有以下循环获得



while(running)

{

锁定本地(互斥);

}
hello group,

is there a chance for other functions to get the lock if i have
following loop:

while (running)
{
Lock local(mutex);
}



是 - 该代码与


相同而(运行){

mutex.lock();

mutex.unlock() ;

}

yes - that code is the same as

while (running) {
mutex.lock();
mutex.unlock();
}


>

如果没有,是否足以改变范围:


while(跑步)

{

{

锁定本地(互斥);

}

}
>
if not, is it enough to change scope:

while (running)
{
{
Lock local(mutex);
}
}



没有区别。

Makes no difference.


Chris Forone写道:
Chris Forone wrote:

你好组,


如果我有其他功能可以获得锁定

foll欠循环:


而(跑步)

{

锁定本地(互斥);

}


如果没有,是否足以改变范围:


while(running)

{

{

锁定本地(互斥);

}

}
hello group,

is there a chance for other functions to get the lock if i have
following loop:

while (running)
{
Lock local(mutex);
}

if not, is it enough to change scope:

while (running)
{
{
Lock local(mutex);
}
}



你可能想要:


{

锁定本地(互斥);

while(running)

{

...

}

}

You probably want:

{
Lock local(mutex);
while(running)
{
...
}
}




" Paul Brettschneider" < pa ***************** @ yahoo.frwrote in message

news:92 ************* *************@news.chello.at ..

"Paul Brettschneider" <pa*****************@yahoo.frwrote in message
news:92**************************@news.chello.at.. .

Chris Forone写道:
Chris Forone wrote:

> hello group,

是如果我有以下循环,其他功能有机会获得锁定:

while(运行)
{
Lock local(mutex);
}
如果没有,是否足以改变范围:

while(运行)
{
{
Lock local(mutex) );
>hello group,

is there a chance for other functions to get the lock if i have
following loop:

while (running)
{
Lock local(mutex);
}

if not, is it enough to change scope:

while (running)
{
{
Lock local(mutex);
}
}



你可能想要:


{

锁定本地(互斥);

而(运行)

{

...

}

}


You probably want:

{
Lock local(mutex);
while(running)
{
...
}
}



为什么?

Why?


这篇关于互斥/锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆