A comment was posted to last week’s blog on IBM i Job Structures. It read:
Dawn: This job structure article jogged my memory regarding a recent situation which I witnessed with an i customer. They have multi-threaded INTERACTIVE jobs running on their system. Can you sometime explain the concept of multi-threaded interactive jobs? I know and understand multi-threaded batch jobs but know nothing about multi-threaded interactive jobs. How are they created? What purpose do they serve? From a performance standpoint, does QPFRADJ adjust activity levels for multi-threads of interactive jobs? Any additional info would be helpful. Thanks!
An IBM i programmer cannot create secondary threads in an interactive job; the allow multiple threads parameter on job descriptions is ignored for interactive jobs and you will receive an error if you attempt to run a program that starts secondary threads when in an interactive job. This is because interactive jobs are not thread safe. One reason interactive jobs are not thread safe is because I/O to display devices is not thread safe.
So how can a multithread interactive job be created?
Threads were introduced to the system in V4R2. In V4R4, the threads support was extended to add “system threads.” System threads are threads of execution used for system functions and can be created in any job, including interactive jobs and jobs that have the allow multiple threads job attribute set to *NO. Because system threads can only be used by operating system developers, there are expectations for how those threads are used to ensure thread safety issues do not occur. Java uses system threads and several Db2/SQL functions in the operating system also use system threads for parallel operations.
You’ll find no documentation in the IBM i Knowledge Center on system threads. There are bits of documentation, however, that will give you small clues about them. For example, the command help for the allow multiple threads parameter includes the following statement: “Specifies whether or not the job can run with multiple user threads. This attribute does not prevent the operating system from creating system threads in the job.”
This blog post was originally published on IBMSystemsMag.com and is reproduced here by permission of IBM Systems Media.