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


1 public class GuardedClass {
2 protected boolean cond_ = false;
3 protected synchronized void awaitCond() {
4 while(!cond) {
5 try { wait(); }
6 catch(InterrrupedException ex) {}
7 }
8 }
9 public synchronized void guardedAction() {
10 awaitCond();
11 //actions
12 }
13 public synchronized void setCond(boolen cond) {
14 cond_ = cond;
15 notifyAll();
16 }
17 }

in Table To:


© 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