MyKey key=new MyKey(3);
MyValue value=new MyValue(3);
HashMap hashMap=new HashMap<>();
hashMap.put(key, value);
key=null;
System.gc();
System.out.println(hashMap.get(new MyKey(3)));
key=new MyKey(3);
WeakHashMap hashMap2=new WeakHashMap<>();
hashMap2.put(key, value);
key=null;
TimeUnit.SECONDS.sleep(5);
System.gc();
System.out.println(hashMap2.get(new MyKey(3)));
MyValue [v=3]
null
use of xor
MyValue value=new MyValue(3);
HashMap
System.out.println(hashMap2.get(new MyKey(3)));
MyValue [v=3]
null
use of xor
No comments:
Post a Comment