Basic HTML version of Foils prepared May 19 99

Foil 32 Guarded Suspension - Example

From Elements of Concurrent Programming in Java Tango Group Internal Technology Seminars -- Spring 99. by Lukasz Beca


public class GuardedClass {
protected boolean cond_ = false;
protected synchronized void awaitCond() {
while(!cond) {
try { wait(); }
catch(InterrrupedException ex) {}
}
}
public synchronized void guardedAction() {
awaitCond();
//actions
}
public synchronized void setCond(boolen cond) {
cond_ = cond;
notifyAll();
}
}



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed May 19 1999