Tidies up the thread-local COBOL run-time environment.
Restriction: This function is supported for native COBOL only.


#include "cobmain.h"

int cobthreadtidy(void);




This function deinitializes the COBOL environment for the current thread, cleaning up any thread-state information and freeing any data allocated as thread-local. It returns 0 on success.

This function can be used only when the current thread was created by non-COBOL API calls;  that is, if the thread was created by C library, operating system or third-party threading API calls. It must not be called if the thread was created by COBOL syntax or the CBL_THREAD_CREATE library routine. You cannot call cobthreadtidy() directly from a COBOL program.

You should call this function only when all COBOL modules have been exited in this thread and you do not intend to reenter them. If you do call any COBOL entry points or COBOL routines (such as cobinit()) after you have called cobthreadtidy(), the results are undefined.

Equivalent COBOL Syntax:



When a C thread is created, you need to specify a C function that is the initial entry point for the thread. If this entry point is c_thread(), then the following shows how to:

  • Call a COBOL entry point cobep which takes no arguments
  • Call cobthreadtidy() before the thread dies
    cobinit();                  /* Only required if not   */
                                /* already called in this */
                                /* process                */
    cobcall("cobep", 0, NULL);  /* Call COBOL */
    cobthreadtidy();            /* Tidy up COBOL in this  */
                                /* thread */  

    return 0;                   /* Exit thread */