24 lines
640 B
Plaintext
24 lines
640 B
Plaintext
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
|
|
|
|
----
|
|
public void doSomething(Object obj)
|
|
{
|
|
lock (this) //first lock
|
|
{
|
|
lock (obj) { // second lock
|
|
// ...
|
|
Monitor.Pulse(obj); // Noncompliant; only the second lock is released
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
ifdef::rspecator-view[]
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::rspecator-view[]
|