COM Apartments and threading
843829Jan 7 2003 — edited Feb 8 2003I have a COM component in a DLL. I instantiate and use the COM Component within an ordinary DLL via native methods. Now i use CoInitialize and CoCreate in the process attach.
Now the Java class that has the native methods was originally single threaded and everything worked fine. I then implemented Runnable and moved the calling code to the run() and then the VM began to crash. I felt that the object was getting destroyed incorrectly.
I was able to solve the problem by not actually doing loadLibrary in a static block but in a separate method which i explicitly called in the run() before making the rest of the calls. Now it appears the coinitialize and Cocreate are happening in the correct thread context and there is no problem.
I would like to know if there is any serious problem in making multiple calls to loadLibrary( ).
thanks in advance
- shyamal