Given the following requirements, could someone post a very simple code sample illustrating how you could use multi-threading, and at the same time properly utilize locks to keep the shared data "safe"?

Say you declare an integer x to be 100. Then, you want to spawn off 10 threads to each perform some action. As each thread completes the action, it decrements x. I know you can use interlocked for this, but wouldn't you also need a lock when you evaluate the condition? In other words, you need to make sure that x is greater than 0 before you perform the action.