



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: ADVANCED PARALLEL PROGRAMMING; Subject: Computer/Information Sciences; University: University of Delaware; Term: Unknown 1989;
Typology: Study notes
1 / 27
This page cannot be seen from the preview
Don't miss anything!




















Dept of Computer & Information Sciences University of Delaware The Problem with Threads
Problem w/ threads – WHY?
public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valueChanged(int newValue); } public void addListener(Listener listener) { listeners.add(listener); }
public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valueChanged(int newValue); } public void addListener(Listener listener) { listeners.add(listener); } public void setValue(int newValue) { value = newValue; Iterator i = listeners.iterator(); while(i.hasNext()) { ((Listener)i.next()) .value Changed(newValue); }
public class ValueHolder { private List listeners = new LinkedList(); private int value; public interface Listener { public void valueChanged(int newValue); } public synchronized void addListener(Listener listener) { listeners.add(listener); } public void setValue(int newValue) { List copyOfListeners; synchronized(this) { value = newValue; copyOfListeners = new LinkedList(listeners); } Iterator i = copyOfListeners.iterator() ; while(i.hasNext()) { ((Listener)i.next()).value Changed(newValue); }
Observer pattern implemented using rendezvous based coordination language
Deterministic interleaving using rendezvous