I’ve found that unity container passes a reference to lifetimeContainer field (of type LifetimeContainer) to the builder. LifetimeContainer is not thread safe and not immutable, and I didn’t found any synchronization logic in the methods accessing it.
For example LifetimeStrategy queries LifetimeManagerFactory, which will write to lifetime container when lifetimeType implements IDisposable interface (consider public ILifetimePolicy CreateLifetimePolicy() method).
Also, if you create child container with CreateChildContainer() method, they will add themself to its parent container’s livetime container during creation and remove when disposing. So, disposing child containers from separate threads may lead to errors,
even each child container accessed only by one thread at time.
When using custom strategies and policies, you should always consider that it may be accessed from different threads. For example SingletonLifetimePolicy written with such consideration but some custom components mind not and mind be sources of errors.
I think that the documentation really lacks good explanation of unity container usage rules in multithread environments and considerations must be taken when developing custom policies and strategies. This is an actual problem, because unity containers frequently
used in multithread applications, such as WCF services and asp.net sites (as an instance providers and web page initializes accordingly).
And I'm really interested is UnityContainer.Resolve method *always* thread safe?
P.S.: sorry for my English.