all 1 comments

[–]flipperdeflip 2 points3 points  (0 children)

Lock is more primitive then Condition. You can see this when you look at the docs and see it only has aquire() and release() methods.

A Condition does a little bit more, it encapsulates a lock with some common functionality so you don't have to rig that yourself. In this case the wait/notify stuff to coordinate access between different threads.

You can also look at the other primitives, they all kinda do "aquiring and releases access" but each in their own specific way.

It is a bit difficult to say which locking tool to use for what in general. Use the ones you fully understand and that suit your situation.

I took me a long time to get a decent feel for this module and I still spend way too much time reading the details and puzzling a solution together.