Program running as long the runtime is active


we are trying the following:

when the user starts a runtime we want the initial program A to call a little program B (as a thread) that runs independently as long as the runtime is running.

Even if for example program A calls program C with CALL PROGRAM.


Is this possible ? How would you achive this ?

The thread was our first idea. If you come up with something other than thread we are open for your solution.

  • Hello,
    indeed, the best way of doing this is using a thread.
    You can find a sample in the Thread Demo sample (Source: custrpt.cbl)
    Best regards,
  • Thanks for your answer.

    Are you sure the thread will continue after the calling program A has called another "main program" via CALL PROGRAM ?

    Or do these rules apply:

    The CALL PROGRAM verb is similar to the CHAIN verb. It causes the current run unit to terminate and initiates a new run unit.
    When the called program exits, its thread is terminated.
  • Hi,
    when you use CALL THREAD "PROGRAM-B" program-b keeps running until it is terminated by the user or when the processing has finished, or until the main-program is terminated. We make sure of that by using STOP THREAD in the main-program. Program-b should have GOBACK instead of STOP RUN in it's closing routine.
    Be aware that you not calling the main-program from program-b, because you will create a loop which will give unpredictable results.
  • For clarification 'CALL PROGRAM <program name>' and 'CALL <program name>' are two different operations. You can NOT use CALL PROGRAM for the scenario you are describing. Thread usage is only available with the CALL operation as described by ruudh.
  • Thanks DougP, that was exactly my state of knowledge ... unfortunately.

    So we have to look for another solution to our problem.