CL commands and thread safety

The Integrated Language Environment® (ILE) CL run time and compiler-generated code are threadsafe. Original program model (OPM) CL programs are not threadsafe.

For any ILE CL code that is compiled before Version 4 Release 3, or for any OPM CL code, the CL run time sends a CPD000B diagnostic message and continues to run with unpredictable results. This might or might not be threadsafe, depending on the underlying code.

Command analyzer is threadsafe. For a given command, if the threadsafe attribute (THDSAFE) is *NO and the multithreaded job action attribute (MLTTHDACN) is set to *NORUN or *MSG, the command analyzer does one of the following operations when such a command is called in a job capable of multithreaded operations:

  • If MLTTHDACN is set to *NORUN in a multithreaded job, command analyzer sends a CPD000D diagnostic message, and the command does not run. A CPF0001 escape message then follows the CPD000D diagnostic message.
  • If MLTTHDACN is set to *MSG in a multithreaded job, command analyzer sends a CPD000D diagnostic message, and the program continues to run with unpredictable results.
  • If the job is capable of running multiple threads but is not actually multithreaded, command analyzer allows commands that are not threadsafe to run without interference.

If MLTTHDACN is set to *RUN, the command analyzer does not send a diagnostic message and allows the command to run. The results of this are unpredictable. Also, MLTTHDACN only applies to commands whose THDSAFE value is *NO. To determine the THDSAFE and MLTTHDACN values for a command, use the Display Command (DSPCMD) command.

The MLTTHDACN value of some commands is set to *SYSVAL. In this case, command analyzer uses the QMLTTHDACN system value to decide how to process the command.

To display the setting of this value on the IBM® i operating system, use the following command:

DSPSYSVAL SYSVAL(QMLTTHDACN)

To change the setting of this value on IBM i, use the following command:

CHGSYSVAL SYSVAL(QMLTTHDACN) VALUE(x)

Sample output from DSPSYSVAL:

 Display System Value 

 System value . . . . . : QMLTTHDACN 
 Description . . . . . : Multithreaded job action 


 Multithreaded job 
 action . . . . . . . : 2 
 1=Perform the function that is not 
 threadsafe without sending a message 
 2=Perform the function that is not 
 threadsafe and send an informational 
 message 
 3=Do not perform the function that is 
 not threadsafe