Running threaded programs
When you run a threaded program, the job that runs a threaded program must be specially initialized by the system to support threads. Currently, several mechanisms allow you to start a job that is capable of creating multiple kernel threads:
- Use the IBM® i QShell Interpreter. In the QShell Interpreter, a program
gets descriptors 0, 1, and 2 as the standard files; the parent and child I/O is
directed to the console. The QShell interpreter allows you to run multithreaded
programs as if they were interactive. See Qshell
for a description of the QIBM_MULTI_THREADED shell variable,
which, when set to 'Y', allows you to run multithreaded programs the same way
you run any other program. The QShell Interpreter is option 30 of Base
- Use the spawn() API. The spawn() API has
a flag in the spawn inheritance structure that allows you to turn on the
multithread capability for the child job. The QUSRTOOL library
also provides source code and an example CL command to allow you to create and
use a SPAWN CL command in a way that is similar to the
SBMJOB CL command. See the SPAWN CL
command, QUSRTOOL example for more information.
- Use the SBMJOB CL command. Setting the 'Allow multiple
threads' parameter (keyword ALWMLTTHD) on the CL command
allows you to turn on the multithread capability of the submitted job.
- Use the CRTJOBD CL command to create a special job description; then create your job using a mechanism that will use the job description. Setting the 'Allow multiple threads' parameter (keyword ALWMLTTHD) on the job description allows you to turn on the multithread capability of the jobs that are created using that job description.