怎么死锁? [英] How did it dead lock?

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

问题描述



有时我的程序会停止,当我打破它时,我看到2个线程

等待锁定语句试图锁定同一个对象。如果我看起来这些线程的调用堆栈中没有任何其他调用来锁定

语句,所以我不知道它是如何可能的什么都可以上锁。


有人能解释一下吗?


谢谢

解决方案




是否有可能是你刚才提到的另一个线程

持有锁?


Brian

eu ***** *@hotmail.com 写道:


有时我的程序会停止,当我打破它时,我看到两个线程都在等待锁定语句试图锁定同一个对象。如果我看起来这些线程的调用堆栈没有任何其他调用锁定
语句,所以我不知道如何锁定任何东西。

任何人都可以向我解释一下吗?

谢谢




您好,

我不这么认为,没有任何其他线程的源代码

可用

Brian Gideon写道:< blockquote class =post_quotes>

你刚刚提到的另外一个线程是否可以锁定?

Brian

eu******@hotmail.com 写道:


有时我的程序停止,当我打破它时,我看到两个线程都在等待锁定语句试图锁定同一个对象。如果我看起来这些线程的调用堆栈没有任何其他调用锁定
语句,所以我不知道如何锁定任何东西。

任何人都可以向我解释一下吗?

谢谢




如果你试图锁定(这)然后它可以导致死锁。你尝试使用SOS / Windbg确定死锁和堆栈跟踪吗?

还发布了一个代码。


Hi,
Sometimes my program stops and when I break it I see 2 threads both
waiting at a lock statement trying to lock the same object. If I look
up the call stack of these threads there aren''t any other calls to lock
statements so I don''t see how it''s possible for anything to be locked.

Can anyone explain this to me?

Thanks

解决方案

Hi,

Is it possible that another thread other than the 2 you just mentioned
is holding the lock?

Brian

eu******@hotmail.com wrote:

Hi,
Sometimes my program stops and when I break it I see 2 threads both
waiting at a lock statement trying to lock the same object. If I look
up the call stack of these threads there aren''t any other calls to lock
statements so I don''t see how it''s possible for anything to be locked.

Can anyone explain this to me?

Thanks




Hello,

I don''t think so, there aren''t any other threads with source code
available
Brian Gideon wrote:

Hi,

Is it possible that another thread other than the 2 you just mentioned
is holding the lock?

Brian

eu******@hotmail.com wrote:

Hi,
Sometimes my program stops and when I break it I see 2 threads both
waiting at a lock statement trying to lock the same object. If I look
up the call stack of these threads there aren''t any other calls to lock
statements so I don''t see how it''s possible for anything to be locked.

Can anyone explain this to me?

Thanks




If you are trying to lock(this) then it can lead in to dead locks. Did
you try using SOS/Windbg to identify the dead lock and the stack trace?
Also post a smaple code.


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

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