Hamm Tia
Hamm Tia

Reputation: 11

.NET SyncLock order deadlock

If I have two Synclocks

synclock a
  synclock b
  end synclock
end synclock

am I in danger of a deadlock if I never have

synclock b
  synclock a
  end synclock
end synclock

in my code, but I do synclock on a or b randomly?

Upvotes: 1

Views: 778

Answers (1)

Hans Passant
Hans Passant

Reputation: 941605

As long as you always lock a before b then you'll be okay.

Upvotes: 3

Related Questions