`
f543711700
  • 浏览: 322917 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

ConcurrentHashMap在惠普Unix上的问题

 
阅读更多

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上面也比较特殊,具体不细说了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics