R
Rüdiger Klaehn
Hi all,
is there a way to check if the current thread owns a monitor? I have
an internal method that assumes that it is always called when a
monitor is held by the current thread. Of course I could just lock on
this again, but I want to a) avoid the overhead for this and b)
validate that the caller fulfills the contract.
By the way: is there a separate news group for multithreading
questions?
best regards,
Rüdiger
---
public void PublicMethod()
{
lock(mLock) {
PrivateMethod();
}
}
// this method should only be called with a lock on mLock by the
current thread.
private void PrivateMethod()
{
Debug.Assert( /* the current thread has a lock on mLock */);
// do something short that requires synchronization
}
private readonly object mLock=new object();
is there a way to check if the current thread owns a monitor? I have
an internal method that assumes that it is always called when a
monitor is held by the current thread. Of course I could just lock on
this again, but I want to a) avoid the overhead for this and b)
validate that the caller fulfills the contract.
By the way: is there a separate news group for multithreading
questions?
best regards,
Rüdiger
---
public void PublicMethod()
{
lock(mLock) {
PrivateMethod();
}
}
// this method should only be called with a lock on mLock by the
current thread.
private void PrivateMethod()
{
Debug.Assert( /* the current thread has a lock on mLock */);
// do something short that requires synchronization
}
private readonly object mLock=new object();