[643] in java-interest
Language issue: thread synchronisation
daemon@ATHENA.MIT.EDU (Mathew Lodge)
Mon Jul 10 18:13:54 1995
Date: Mon, 10 Jul 1995 10:19:20 -0600
From: lodge@houston.omnes.net (Mathew Lodge)
To: java-interest@java.Eng.Sun.COM
I've been reading the white paper on Java, which states:
"Java thread support includes a sophisticated set of synchronization
primitives based on the widely used monitor and condition variable paradigm
introduced twenty years ago by C.A.R. Hoare"
The example given shows how access to an object is controlled by using an
implicit monitor -- when a synchronised class method is entered, it
acquires a monitor automagically.
The fact that the monitor is acquired implicitly is Good News IMHO -- a
whole class of programming errors are eliminated (e.g. forgetting to
release the monitor before exiting).
Serialising access to objects is one thing. However, it is not clear how
two Java threads can synchronise their activities. Say one thread wants to
wait for another to complete to reach a certain stage before continuing --
how is that done efficiently (i.e. without doing polling) ?
I am also worries by the phrase "condition variable paradigm". Does this
mean there are semaphores in Java? Java avoids the usual C/C++ worries over
dynamically allocated memory and so frees the programmer from a large
number of typical programming errors. Semaphores are the concurrent
programming equivalent of malloc(): good primitives, but extremely error
prone to use -- there are much better synchronisation paradigms out there!
A lot of water has passed under the concurrent programming bridge since
Hoare's monitors and Djikstra's semaphores, and it would be a real shame if
Java got stuck with error prone and unecessarily primitive synchronisation
primitives.
Can someone tell me if my fears are unfounded -- and is there a Java
language reference manual anywhere?
Thanks,
Mathew
| Mathew Lodge | "There's nothing intellectual about |
| lodge@houston.omnes.net | wandering around Italy in a big shirt |
| Omnes, Houston, Texas, USA | trying to get laid" - Blackadder III |
| Phone: +1 713 513 3237 Fax: +1 713 513 3126 |
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com