[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Aikido language




You may want to consider an alternative where there is no implicit
condition variable and multiple explicit condition variables are allowed.
The implicit condition variable seems to be the target of criticism of
Java monitors. See the following paper for an outline of the argument.

Advanced Thread Synchronization in Java

http://citeseer.nj.nec.com/551808.html


regards,

Eli


On Tue, 3 Feb 2004, David Allison wrote:

>
> On 3 Feb 2004, at 20:14, Neelakantan Krishnaswami wrote:
>
> > David Allison writes:
> >>
> >> * multithreaded, with monitors
> >
> > Can you say some more about this? Does each object have its own lock,
> > a la Java?
> >
>
> There are two types of monitors available:
>
> 1. Ada-style synchronized classes where each instance of the class is
> mutex
>     locked.  Example:
>
>     import queue
>
>     monitor WorkQueue {
>         var queue = new Queue()
>
>         public function put (item) {
>            queue.put (item)
>            notify()
>        }
>
>        public function get() {
>             while (queue.empty()) {
>                 wait()
>             }
>             return queue.get()
>      }
> }
>
> var q = new WorkQueue()    	// access is mutex locked
>
> This is very convenient and easy to understand for the programmer.
>
> 2. Java-style monitors, where a monitor can be attached to an object and
>     you can have synchronized methods for access to the object.  Not
> every
>     function on the object is locked, just the ones you specify as
> synchronized.
>
>
>      class Whatever (public y) extends Whoever {
>         synchronized public function thisislocked (x) {
>         }
>
>         public function notlocked() {
>         }
>      }
>
> There is also a synchronized statement to allow a statement to be
> locked (exactly
> like Java)
>
>     synchronized (this) {
>         dosomething()
>     }
>
> Note that there is not a pointer to a monitor attached to every object
> - that would
> be wasteful.
>
> Dave
>
> > --
> > Neel Krishnaswami
> > neelk@cs.cmu.edu
> >
>
>