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

Re: Aikido language

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 
    locked.  Example:

    import queue

    monitor WorkQueue {
        var queue = new Queue()

        public function put (item) {
           queue.put (item)

       public function get() {
            while (queue.empty()) {
            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 
    function on the object is locked, just the ones you specify as 

     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) {

Note that there is not a pointer to a monitor attached to every object 
- that would
be wasteful.


> -- 
> Neel Krishnaswami
> neelk@cs.cmu.edu