"Olaf Meding" <[EMAIL PROTECTED]> writes:

>> return result   before that line, some other thread added a value !
>
> Sure, but that is the nature of using threads and a mutex.  I hope you are
> you not saying that every function that uses a mutex should have a comment
> saying this is not "reliable"?

Strictly speaking, mutex has nothing to do about it, -- if there were no
mutex there the problem would have been even worse, so this is the
nature of accessing shared resources by multiple threads.

Somewhat similar example is accessing a file after checking for its
existence in a multi-tasking OS:

    if fileExists(fileName):
        openFile(fileName)

has the same problem, -- at open_file time one can't rely on existence
of the file, so the check for existence is useless.

-- 
Sergei.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to