class sample { Object myLock = new Object(); public void DoSomething() { lock(myLock) { // do something here } } }