The information in this article applies to:
SYMPTOMS
When using COM objects in a multi-threaded Java application, calls on apartment-threaded COM objects are serialized, even when the objects are created on their own threads. COM rules state that only one thread may exist in a Single Threaded Apartment (STA), and all calls to any object in that apartment must be serviced by the apartment's one and only thread. CAUSEThis behavior saves work for you, the developer, because you don't need to implement a message loop to pump messages for STAs. When using only a few apartment-threaded COM objects, this behavior is a boon to the developer; however, when using many apartment-threaded objects, this behavior can be a significant performance hit. Fortunately, it is easy to override this default behavior. RESOLUTION
In order to tell the Microsoft virtual machine that your Java thread is COM-friendly and that you have every intention of pumping messages for the STA in which it will reside, you use the ComLib.declareMessagePumpThread() method. See the example in the More Information section of this article.
STATUSThis behavior is by design. MORE INFORMATIONThis sample was taken directly from Chad Verbowski's excellent article, "Using COM Objects from Java."
REFERENCESFor the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java,
please see the following pages on the Microsoft Technical Support site: http://support.microsoft.com/support/visualj/ For more information about Java-COM integration, consult the SDK for Java documentation and samples, and the Java Technologies' Technical Articles page. Additional query words:
Keywords : kbCOMt kbJava kbJavaVM kbSDKJava kbVJ kbGrpJava |
Last Reviewed: November 16, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |