Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the synchronized keyword in Java called 'synchronized' instead of the more precise 'mutexed'?

I've heard that choosing to use the word 'synchronized' to describe mutexed statements is simply a mistake (Edit: 'mistake' was a bad choice of words here. Please see edit) in Java, but I'm wondering if there is actually a reason behind the choice.

[Edit]

Prodded by Safyan's comments, I would like to add that synchronization is a general term for establishing timing relationships between threads. It can include mutual exclusion and things like rate control (eg. two threads doing something at the same rate). It appears unnecessarily ambiguous to use 'synchronized' to mean mutual exclusion instead of a more specific keyword like 'mutexed'.

like image 410
Edward D'Souza Avatar asked Apr 27 '10 03:04

Edward D'Souza


1 Answers

It is not a mistake. It means what it says; the code has to synchronize with other threads to provide mutual exclusion. And, in fact, the term synchronized may make more sense than "mutex", since "mutex" implies a very particular type of synchronization primitive, and the synchronized keyword could be implemented using any number of thread syncrhonization primitives (test&set with active polling, semaphores, etc.).

like image 86
Michael Aaron Safyan Avatar answered Sep 30 '22 14:09

Michael Aaron Safyan