Note that there are some explanatory texts on larger screens.

plurals
  1. PODeadlock clarification?
    primarykey
    data
    text
    <p><em>Maybe there is other interpretation of "Dead Lock" but AFAIK :</em> </p> <p><a href="http://books.google.co.il/books?id=t1de8nSVYnkC&amp;pg=PA882&amp;lpg=PA882&amp;dq=%22A%20deadlock%20happens%20when%20two%20threads%20each%20wait%20for%20a%20resource%20held%20by%20the%20other,%20so%20neither%20can%20proceed.%22&amp;source=bl&amp;ots=24seVuLjaz&amp;sig=ApUJDxRvzk0WEMoq67JVJBeeE8s&amp;hl=en&amp;sa=X&amp;ei=z9YnUZ_zIorLswb1wIHYBA&amp;redir_esc=y#v=onepage&amp;q=%22A%20deadlock%20happens%20when%20two%20threads%20each%20wait%20for%20a%20resource%20held%20by%20the%20other,%20so%20neither%20can%20proceed.%22&amp;f=false" rel="nofollow noreferrer">reference</a></p> <blockquote> <p>A deadlock happens when <strong>two threads each wait for a resource held by the other</strong>, so neither can proceed.</p> </blockquote> <p>But I've seen couple of answers here on SO which claims that a long wait ( without waiting for each other) is also a deadlock : </p> <p><strong><a href="https://stackoverflow.com/a/894071/859154">Example #1</a></strong></p> <pre><code>namespace ConsoleApplication7 { public class Program { public static void Main(string[] args) { LockableClass lockable = new LockableClass(); new Thread(new ParameterizedThreadStart(BackgroundMethod)).Start(lockable); Thread.Sleep(500); Console.Out.WriteLine("calling Reset"); lockable.Reset(); } private static void BackgroundMethod(Object lockable) { lock (lockable) { Console.Out.WriteLine("background thread got lock now"); Thread.Sleep(Timeout.Infinite); } } } public class LockableClass { public Int32 Value1 { get; set; } public Int32 Value2 { get; set; } public void Reset() { Console.Out.WriteLine("attempting to lock on object"); lock (this) { Console.Out.WriteLine("main thread got lock now"); Value1 = 0; Value2 = 0; } } } } </code></pre> <blockquote> <p>Pardon me but all I see here is a pure lock that hasn't been released. it is not a situation both threads waiting for another. The Thread here <strong>does NOT</strong> wait for the main thread to finish.</p> </blockquote> <hr> <p><strong><a href="https://stackoverflow.com/a/728920/859154">Another example #2</a></strong></p> <pre><code>class ILockMySelf { void doThat() { lock(this){ ... } } } class WeveGotAProblem { ILockMySelf anObjectIShouldntUseToLock; void doThis() { lock(anObjectIShouldntUseToLock) { // Following line should run in a separate thread // for the deadlock to happen anObjectIShouldntUseToLock.doThat(); } } } </code></pre> <p>Same here. the thread which runs <code>doThis</code> is NOT waiting for the "separate thread" which will run <code>doThat</code></p> <p><strong>Question :</strong> </p> <ul> <li>Are Deadlocks involved here? </li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload