In a mixed language environment, threads created directly by operating system facilities and not by the START verb or the CBL_THREAD_CREATE routine have several restrictions and requirements on them:
- They must be terminated by the approved operating system method of thread termination and not by any function in the CBL_THREAD_n routines (for example, CBL_THREAD_EXIT or CBL_THREAD_KILL).
- Their handles are always created detached. This means that they cannot be waited on by the WAIT verb or by the CBL_THREAD_WAIT routine, and no return value is available from them.
- They must issue the call cobthreadtidy() or cobtidy() when the thread or the application, respectively, no longer needs COBOL run-time system services. This allows the run-time system to free memory and clean up thread-state information.
- cobtidy(), cobexit() or the COBOL STOP RUN statement will cause the calling thread to be treated as the 'main' thread. As a result, the run-time system will wait for all CBL_THREAD_CREATE threads to terminate before any run-time system cleanup processing is completed.
Note: All the multi-threading functions supported by the run-time system detect handles created by threads in other languages, and reports invalid use of them. It is, however, entirely up to the application to ensure that run-time system resources are freed for any thread that has executed any COBOL or run-time system code in the course of its existence (as detailed above).