lock(new object()) — Cargo cult or some crazy “language special case”?

I wouldn’t be suprised if it was someone who saw this:

private readonly object lockObj = new object();

private void MyMethod()
{
    lock(lockObj)
    {
        // do amazing stuff, so amazing it can only run once at a time
        // e.g. comands on the Mars Rover, or programs on iOS pre 4 / 5 ??
    }
}

and thought he could cut the number of lines.

I’d be very worried if that were the case though…

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)