I have a little problem with multithreading and COM. My situation looks like this:
Main progam called main starts 4 threads of the same function these 4 treads gets an instance of the same COM object. Later on these four threads start two other threads that must use the same instance of the starting thread.
This is a "picture" of the threads
main = progam
1,2,3,4 = thread of the same type (same function)
Instansiate a COM object
A,B = Two diffrent threads that needs the pointer
of the instanciated COM object.
main 1 A
This progam work fine when i just use thread 1 that creates A and B but not when i create thread 2,3,4.
Is this a limitation to COM? or do i use the wrong way to create the instancees. I hawe tried both CoCreateIntance(...)
and GetClassObject(...) , CreateInstance(...) Release (...) way but they both result in the same behaviour.
Is it ok to store the pointer to the instance in a global vector (ok not very neat, but are there any problmes)