I think the question is pretty self-explanatory. Do these two keywords have exactly the same effect, or is there something I should be aware of?
A quick google gave me this hit:
Which seems to answer your question, but since it's that easy to find, I'm guessing you're wondering if there's more to it?
One interesting difference not covered in the link posted by Keeg: as far as I'm aware, there's no equivalent method calls in Java for .NET's Monitor.Enter and Monitor.Exit, which the C# lock
statement boils down to. That means you can't do the equivalent of Monitor.TryEnter either - although of course the java.util.concurrent.locks namespace (as of 1.5) has a variety of locks which have more features available.
I java you don't have to worry about locking public types that you own.
In .NET, you have to
Updated: this is for types that you own. Locking on public types that you don't own is bad in any language :)