HomeChallengesRepsProblemsLeaderboardTake a challenge

What you lock on

lock(this), lock(typeof(T)) and lock("key"). Three ways to let a stranger deadlock you.

Intermediate15 min on the clock4 graded checks · 100 pointsResources and ConcurrencyPro
Graded by reading your code against the checklist below.

What you build

  • Introduce a private lock object and guard instance state with it
  • Stop locking on the instance itself
  • Stop locking on a type or a string literal
  • Guard the static field with a static lock object

Done means

Every lock is on a private object, with a static gate for the static field.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. Instance state is guarded by a private object+30What you lock on
  2. Nothing locks on the instance+25What you lock on
  3. Nothing locks on a type or a string+25What you lock on
  4. The static field has a static gate+20What you lock on

What it teaches

The rest of Resources and Concurrency