Professional Documents
Culture Documents
Lecture 4
Lecture 4
Lecture Aims
startRead();
// call object to read data structure
stopRead();
startWrite();
// call object to write data structure
stopWrite();
package java.util.concurrent.locks;
public interface Lock {
public void lock();
// Wait for the lock to be acquired.
public Condition newCondition();
// Create a new condition variable for
// use with the Lock.
public void unlock();
…
}
package java.util.concurrent.locks;
public class ReentrantLock implements Lock {
public ReentrantLock();
...
public void lock();
public Condition newCondition();
// Create a new condition variable and
// associated it with this lock object.
public void unlock();
}
Find out more about the Java 1.5 memory model (look for
JSR 133 on the web - this was the name of the group that
developed it.)