Update of /cvsroot/fb-contrib/fb-contrib/samples
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16894/samples
Modified Files:
BSB_Sample.java
Log Message:
unsafe aliases aren't just items that are return values of this calls, but also of methods returned from methods calls on other unsafe aliases
Index: BSB_Sample.java
===================================================================
RCS file: /cvsroot/fb-contrib/fb-contrib/samples/BSB_Sample.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- BSB_Sample.java 29 Jan 2006 19:53:05 -0000 1.5
+++ BSB_Sample.java 1 Feb 2006 06:47:47 -0000 1.6
@@ -1,11 +1,16 @@
+import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
public class BSB_Sample
{
private Object lock = new Object();
private Set<String> info = new HashSet<String>();
-
+ private Map<String, Object> synchMap = Collections.synchronizedMap(new HashMap<String, Object>());
+
public void testFieldBeginBloated(int i, int j)
{
synchronized(lock)
@@ -60,4 +65,15 @@
{
return info;
}
+
+ public void accessSyncMap() {
+ Set keySet = synchMap.keySet();
+ synchronized (synchMap) {
+ for (Iterator it = keySet.iterator(); it.hasNext();) {
+ String key = (String) it.next();
+ Object obj = synchMap.get(key);
+ }
+ }
+ }
+
}
|