Jump to content

Mutex: Difference between revisions

696 bytes added ,  14 years ago
Added Oz.
(→‎{{header|Java}}: - talke about Java's synchronized keyboard)
(Added Oz.)
Line 266:
Mutex.unlock m;</lang>
 
=={{header|Oz}}==
Oz has "locks" which are local, reentrant mutexes.
 
Creating a mutex:
<lang oz>declare L = {Lock.new}</lang>
 
The only way to acquire a mutex is to use the <code>lock</code> syntax. This ensures that releasing a lock can never be forgotten. Even if an exception occurs, the lock will be released.
<lang oz>lock L then
{System.show exclusive}
end</lang>
 
To make it easier to work with objects, classes can be marked with the property <code>locking</code>. Instances of such classes have their own internal lock and can use a variant of the <code>lock</code> syntax:
<lang oz>class Test
prop locking
 
meth test
lock
{Show exclusive}
end
end
end</lang>
 
=={{header|Ruby}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.