wsky / top-push

Message-push abstraction component, provide useful messaging components.
8 stars 4 forks source link

synchronize getLock() #51

Closed wsky closed 10 years ago

wsky commented 10 years ago
@SuppressWarnings("unchecked")
    private Map<Object, Entry<AtomicBoolean, Long>> getLocks(Client client) {
        Map<Object, Entry<AtomicBoolean, Long>> locks =
                (Map<Object, Entry<AtomicBoolean, Long>>) client.getContext(this.contextKey);
        if (locks == null)
            client.setContext(this.contextKey,
                    locks = new HashMap<Object, Map.Entry<AtomicBoolean, Long>>());
        return locks;
    }

not thread safe