CREATE THREAD Service

The CREATE THREAD service acquires and initializes a
RLX
/CAF thread control block.
Before your application program can connect to Db2, it must define an application thread which acts as a carrier of this connection. The CREATE THREAD service is used for this purpose.
CREATE THREAD acquires and initializes a
RLX
/CAF thread control block. Values mapped into the thread control block are furnished as parameters passed on the call or are taken from the
RLX
/CAF profile defaults module.
The CREATE THREAD service causes
RLX
/CAF to attach a new MVS thread subtask for each Db2 plan thread after the first one.
>>---CREATE THREAD(:hv_handle)----------------+---------------------+-------------> | | +-SYSTEM(+---dsn---+)-+ | | +-:hv_dsn-+ >--+--------------------+---+---------------------+---+----------------------+--->< | | | | | | +-PLAN(+---plan---+)-+ +-RLXPGM(+---PGM---+)-+ +-LOAD(+ --ddname---+)-+ | | | | | | +-:hv_plan-+ +-:hv_pgm-+ +-:hv_ddname-+
The CREATE THREAD request causes
RLX
/CAF to perform the following action:
  • Build a thread control block.
  • Initialize it with the name of the Db2 subsystem and application plan that you wish to use.
  • Attach an MVS subtask which provides a SQL interface to Db2.
The CREATE THREAD request returns a thread handle in the host variable denoted in the syntax diagram as
:hv_handle
. This handle must be used on all subsequent
RLX
/CAF calls.
The SYSTEM and PLAN parameters are optional. If the parameters are not coded, the default values stored in the run-time parameter defaults are used. Parameter values are saved in the thread control block and are used in subsequent CONNECT and OPEN requests.
The LOAD parameter identifies a file (DD statement) as a TASKLIB for the application thread process. Call Attach interface routines, such as DSNALI, DSNHLI2, and DSNWLI, are loaded from this library. The
ddname
must be allocated. Otherwise, the CREATE THREAD call fails.
The following example illustrates use of the CREATE THREAD service:
'CAF CREATE THREAD THREAD(:thread) SYSTEM(DSN) PLAN(RLXvrmCS)'
Where
  • THREAD
    Identifies a REXX variable into which a thread handle is returned.
  • SYSTEM
    Identifies the name of the Db2 subsystem to which this thread should connect.
  • PLAN
    Specifies the name of the Db2 application plan to be associated with this thread.
  • PGM
    Specifies the name of the
    RLX
    SQL load module associated with the Db2 application plan specified by PLAN.