rspec/rules/S3046/csharp/rule.adoc

33 lines
773 B
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
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.
2020-06-30 12:48:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,csharp]
2020-06-30 12:48:39 +02:00
----
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)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]