package net.jcip.examples;
import java.util.*;
import net.jcip.annotations.*;
/**
* ThreeStooges
*
* Immutable class built out of mutable underlying objects,
* demonstration of candidate for lock elision
*
* @author Brian Goetz and Tim Peierls
*/
@Immutable
public final class ThreeStooges {
private final Set stooges = new HashSet();
public ThreeStooges() {
stooges.add("Moe");
stooges.add("Larry");
stooges.add("Curly");
}
public boolean isStooge(String name) {
return stooges.contains(name);
}
public String getStoogeNames() {
List stooges = new Vector();
stooges.add("Moe");
stooges.add("Larry");
stooges.add("Curly");
return stooges.toString();
}
}