Map<Class<?>, Object> stickyEvents = new ConcurrentHashMap<>();
public void postSticky(Object event) {
synchronized (stickyEvents) {
stickyEvents.put(event.getClass(), event);
}
post(event);
}
例如,stickyEvents已经使用了支持并发的ConcurrentHashMap,为什么 stickyEvents.put 使用同步?