Commit 68cd84c8 authored by yanzg's avatar yanzg

修改日志打印功能,打印更加详细的日志

parent 91d711d6
package base;
import com.yanzuoguang.util.thread.ThreadHelper;
import org.junit.Test;
import sun.misc.GC;
import java.util.Map;
import java.util.WeakHashMap;
public class WeakHashMapTest {
public static class MyKey{
}
@Test
public void test() throws InterruptedException {
Map<MyKey,Integer> map = new WeakHashMap<>();
test1(map);
System.out.println(map.size());
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while(true){
System.gc();
System.out.println(map.size());
ThreadHelper.sleep(100);
}
}
});
thread.start();
thread.join();
}
private void test1(Map<MyKey,Integer> map ){
map.put(new MyKey(),1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment