Why do it this way

  • Thread starter Alexander Muylaert
  • Start date
A

Alexander Muylaert

Hi

when browsing thrue someone's code, I noticed the following lock mechanism.

Why would someone do it that way?

public class..
private readonly object _Lock = new object();

public int Count {

get {

lock(_Lock) {

return _List.Count;

}

}

Why not just

Lock(this){
return _List.Count;
}
Can somebody give me a clue?

Kind regards



Alexander
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top