1. A method comprising: executing multiple threads on a computer; a thread T 1 acquiring a lock on a top object in a hierarchy of objects, wherein an invariant condition is specified for the top object, the invariant condition specifies a relation on data of the top object, and the invariant condition references at least two fields, wherein the at least two fields are of at least two different objects; wherein acquiring the lock changes ownership to thread T 1 of the top object; wherein ownership confers upon thread T 1 a right to modify any field of the top object; wherein the lock excludes all other threads from accessing the top object and any descendant objects in the hierarchy of objects; after acquiring the lock, unpacking the top object, wherein unpacking the top object comprises designating the top object as being of a mutable state, which allows invariants to be temporarily violated and allows field assignments of the top object that temporarily violate the invariant condition; and packing the top object, wherein packing the top object comprises verifying that the invariant condition holds and taking the top object from the mutable state to designated as being of a consistent state, wherein being designated as being of a consistent state prevents further modifications.