import java.util.Map;
import java.util.WeakHashMap;
public class Main {
public static void main(String args[]) {
final Map map = new WeakHashMap();
map.put(new String("A"), "B");
Runnable runner = new Runnable() {
public void run() {
while (map.containsKey("A")) {
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {
}
System.gc();
}
}
};
Thread t = new Thread(runner);
t.start();
try {
t.join();
} catch (InterruptedException ignored) {
}
}
}