Each thread maintains its own set of nested AST contexts, so when astEnd is called, only Objects that are locked by the current thread will be annulled.
If an Object is unlocked by a thread using astUnlock, it is exempted from context handling so that subsequent invocations of astEnd will not cause it to be annulled (this is similar to using astExempt on the Object). When the Object is subsequently locked by another thread using astLock, it will be imported into the context that was active when astLock was called.
AST A Library for Handling World Coordinate Systems in Astronomy