On 5/30/12 6:39 AM, deadalnix wrote:
Le 30/05/2012 14:43, Regan Heath a écrit :
Not in all cases. If you have a synchronized class, say a thread-safe
container, which has a synchronized lookup and synchronized insert
function, code like..

if (!o.lookup(...))
o.insert(...)

The correct solution is an insertIfNotPresent function, or to
throw/return an error when inserting an item.

Exposing the lock is just spreading the mess.

Agreed on both counts.


Andrei

Reply via email to