I actually have a question about using locks vs synchronized
declaration.

When you convert java to C# there will come a moment you will have to
convert a synchronized method. So you have two options either you slap a
lock(this) around the method's code, or you declare the method
synchronized. This results in different IL code. The first will result
in a monitor + exception handling code, while the latter will actually
result in an IL "synchronized" annotation.

If you run the Java-to-C# converter it will do the first, if you run j#
it will do the latter. 

Jeff Richter in his framework book or in some article, suggests never to
use the declarative approach, as you may "forget" that it is actually
there. I can feel for that, and there are other reason why the explicit
use of monitors may be better.

What I would like to know is whether there are any semantic differences
(at IL level) between an "synchronized" annotated method and a method
whose complete implementation is guarded by a monitor.

--
Werner

Reply via email to