Mixing thread models

Do not mix Pthreads APIs with other thread management APIs that might be provided by the system.

For example, you should not use Java™ or the IBM® Open Class libraries threads implementations in the same thread or process as Pthreads. More importantly, do not attempt to manipulate a thread from one threads implementation with the API of another. Unpredictable results might occur.

For example, you can manipulate the priority of a thread by using Pthread interfaces and non-Pthread interfaces. If you do so, the priority is always set correctly. However, the priority returned from the Pthread interface pthread_getschedparam() is correct only if setting the priority was always done using either the pthread_setschedparam() interface or some other interface, but not both. If you instead use multiple interfaces to set the priority of the thread, pthread_getschedparam() always returns the priority that was set by the last use of the pthread_setschedparam() interface.

Similarly, you can end a Java thread using the pthread_exit() API if you are running application code in a native method. However, using pthread_exit() to end the Java thread can have unexpected repercussions. These can include bypassing some of the Java environment thread processing or perhaps ending the Java thread in a way that your Java application does not expect and cannot handle.