//package base; // //import com.yanzuoguang.util.thread.ThreadHelper; //import org.junit.Test; // //import java.util.ArrayList; //import java.util.List; //import java.util.Map; //import java.util.WeakHashMap; // //public class WeakCallback { // // public static class MyKey { // // } // // // @Test // public void test() throws InterruptedException { // List list = new ArrayList<>(); // // Map map = new WeakHashMap<>(); // test1(map, list); // 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 map, List list) { // MyKey myKey = new MyKey(); // map.put(myKey, 1); // list.add(new Runnable() { // @Override // public void run() { // System.out.println("打印" + myKey); // } // }); // } //}