Created On: 08 October 2010
Problem:
The main program starts many threads specifying a handle for each. For example:
CALL THREAD "PROGNAME" HANDLE IN THREAD1-HANDLE.
The handles are used when sending messages between threads. Some of those threads need to send messages to the main program but it doesn't have a handle.
How can the main program's thread handle be determined?
CALL THREAD "PROGNAME" HANDLE IN THREAD1-HANDLE.
The handles are used when sending messages between threads. Some of those threads need to send messages to the main program but it doesn't have a handle.
How can the main program's thread handle be determined?
Resolution:
To obtain the thread handle of the main program first define it in working-storage:
01 MAIN-THREAD-HANDLE HANDLE OF THREAD.
Then do this in the procedure division before starting any other threads:
ACCEPT MAIN-THREAD-HANDLE FROM THREAD HANDLE.
Then the child threads can send messages to MAIN-THREAD-HANDLE.
01 MAIN-THREAD-HANDLE HANDLE OF THREAD.
Then do this in the procedure division before starting any other threads:
ACCEPT MAIN-THREAD-HANDLE FROM THREAD HANDLE.
Then the child threads can send messages to MAIN-THREAD-HANDLE.
Old KB# 31906



