import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
public class Main {
static ConcurrentHashMap table = new ConcurrentHashMap();
public static void main(String[] args) throws InterruptedException {
table.put("1", "1");
System.out.println("loading success");
new Thread() {
@Override
public void run() {
try {
sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
table.remove("1");
}
}.start();
for(Iterator it=table.entrySet().iterator();it.hasNext();) {
Thread.sleep(2000);
System.out.println("hahahah");
Map.Entry entry=(Map.Entry)it.next();
System.out.println(entry.getKey());
System.out.println(entry.getValue());
table.remove(entry.getKey());
}
System.out.println("main thread compleat");
}
}
以上这段代码在惠普UNIX上面的结果比较特殊,是:
BimsInt2[/]#java Main
loading success
hahahah
1
null
main thread compleat
但是在windows、solaris和linux上面的结果是:
loading success
hahahah
1
1
main thread compleat
另:java里面的new java.util.Date()在惠普UNIX上面也比较特殊,具体不细说了。