Rocket® Enterprise Developer (formerly a product of Micro Focus or formerly a product of Open Text) documentation, created before Rocket Software acquired certain products from OpenText, may include outdated references to "Micro Focus" or "OpenText", both of which are trademarks of OpenText or its affiliates. Rocket Software is not affiliated with Micro Focus or OpenText and has since rebranded these products as Rocket® products. You may also encounter outdated links in this documentation. If you do, please contact Rocket Support (support@rocketsoftware.com) for assistance.
Using the Program Thread-locking Routines
The following code at the entry to a program ensures that only the first thread entering a program will initialize data and all following threads will have that preinitialized data available:
if first-time = 0
call "cbl_thread_prog_lock"
if first-time = 0
initialize my-data-division
move 1 to first-time
end-if
call "cbl_thread_prog_unlock"
end-if
Note the double check of the
first-time variable. The first check is an optimization that avoids the overhead of locking the program if we know for sure that it has already been initialized.