a) * , . * equals/hashCode, ConcurrentHashMap. . 40 .
b) -, , .. 100 ( , ). , . ~ 12 (.. ArrayList).
c) , AtomicBitSet java. . . , , , (~ 40 ConcurrentHashMap AtomicBitSet).
, / . :
lock map: objectId -> {true | false}
lock map: bucket of objectIds -> {true | false}
:
lock map: objectId -> {ReadWriteLock lock, Thread owner, long writeLockGrantedAtMs}
, . , ReadWriteLock. writeLockedAtMs owner, .
ADDED
, , , , .. hashCode . , . :
void lockObjects (f, e, a) {
reorder (f, e, a)
if(!tryLock(a, timeout: 10ms)){
throw "could not lock a";
}
if(!tryLock(e, timeout: 10ms)){
throw "could not lock e";
}
if(!tryLock(f, timeout: 10ms)){
throw "could not lock f";
}
}
) 3 , 1-2 . , , .
, Colony Character, . , / , .
Colony Character s, , .. Colony Character ( ) . , - , .