Threading needs to be considered both at build time and at run time. The application design considerations are described here, the build time requirements are described in Threading build time considerations.
The session initialize should be performed before any other threads have started. All threads should finish before the session terminate is called; this includes all threads that might be involved in callback style operations.
Due to the underlying Java VM, the same threading model needs to be used in the application. In the case of the Sun and IBM JDKs this means that native Win32 threads should be used. In addition these JDKs used the MSVCRT C Runtime library, and this should be used in the application.
When a new thread wishes to access any WebSphere MQ Everyplace API function it must call the threadAttach function (found in the session API). When the thread has finished using the WebSphere MQ Everyplace API ( this could be well before the thread terminates) it should call the threadDetach function.
Failure to call the threadDetach function prior to the thread terminated (either naturally or forced) results in the system being put into an unstable state. This could result in premature failure.
Notes: