views:

80

answers:

1

What is the difference between synchronized and lock?

Thx.

+2  A: 

synchronized is a language keyword; Locks are objects.

When a method or block of code is marked synchronized, you are saying that some lock object (which could be specified in the syntax of synchronized) must be obtained by the method or block before it can be executed.

Brabster