OdeToCode IC Logo

What's Wrong With This Code? (#13)

Tuesday, March 27, 2007

 

For lucky #13, I want to know what can go terribly wrong with the following code, and why.

class HardWorker
{        
    
public void DoMultiThreadedWork(object someParameter)
    {
        
lock (lockObject)
        {
            
// ... lots of work ...
        }
    }

    
private string lockObject = "lockit";
}

 

Hint: Think about memory optimizations in the CLR.