
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
45 lines
1.1 KiB
Plaintext
45 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The ``++Monitor.Pulse++`` call releases the object on which it was called and wakes up the first thread waiting for the lock on that object. Significantly, it only releases _one_ lock, and if multiple locks are held when it is called deadlocks could result.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
public void doSomething(Object obj)
|
|
{
|
|
lock (this) //first lock
|
|
{
|
|
lock (obj) { // second lock
|
|
// ...
|
|
Monitor.Pulse(obj); // Noncompliant; only the second lock is released
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove this "Monitor.Pulse" call; it only releases the lock on "xxx", leaving the one on "yyy" intact.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 16 Jun 2015, 11:21:35 Tamas Vajk wrote:
|
|
\[~ann.campbell.2], could you please go through this C# specific version of the rule?
|
|
|
|
=== on 16 Jun 2015, 13:35:03 Ann Campbell wrote:
|
|
Looks good [~tamas.vajk]
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|