diff -r 000000000000 -r 08dd52950883 samples/deadlock/test/org/apidesign/javamonitorflaws/MultiplyCache.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/deadlock/test/org/apidesign/javamonitorflaws/MultiplyCache.java Tue Feb 10 18:36:21 2009 +0100 @@ -0,0 +1,43 @@ +package org.apidesign.javamonitorflaws; + +import org.apidesign.javamonitorflaws.Cache; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +/** + * + * @author Jaroslav Tulach + */ +public class MultiplyCache extends Cache { + private PropertyChangeSupport pcs; + private int multiply; + public static final String PROP_MULTIPLY = "multiply"; + + public synchronized int getMultiply() { + return multiply; + } + public synchronized void setMultiply(int multiply) { + int oldMultiply = this.multiply; + this.multiply = multiply; + pcs.firePropertyChange(PROP_MULTIPLY, oldMultiply, multiply); + } + + public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { + if (pcs == null) { + pcs = new PropertyChangeSupport(this); + } + pcs.addPropertyChangeListener(listener); + } + public void removePropertyChangeListener(PropertyChangeListener listener) { + if (pcs != null) { + pcs.removePropertyChangeListener(listener); + } + } + + @Override + protected Integer createItem(String f) { + return f.length() * getMultiply(); + } + + +} \ No newline at end of file