Top
NetCOBOL V11.0 Getting Started
FUJITSU Software

A.22 Sample 21: Multi-Thread Programming

Sample 21 demonstrates how COBOL can support multithreading programming.

In sample 21, a resource (file data) is shared between threads, and the synchronous control between threads is shown by using the multi-thread programming functions of NetCOBOL.

Please refer to Chapter 22, "Multithread Programs” of the “NetCOBOL User's Guide” for details of the multi-thread programming functions of NetCOBOL.

Sample 21 is a Web application. Web applications typically can benefit from multithreading applications.

Please refer to the "NetCOBOL Web Guide" and the "NetCOBOL ISAPI Subroutines User's Guide" for details of the functions available for programming the Web.

To execute this sample, the following products are needed on the client side and the server side.


Client side

Server side

Overview

The sample program consists of the following three parts.

This sample demonstrates how to share resource data with Web functions, and how to synchronize the threads.

Available Programs

Process Flow

  1. Business start and end

  2. Authorization service

Applicable COBOL Functions

Applicable COBOL Statements

The CALL, CLOSE, EXIT, GO TO, IF, MOVE, OPEN, PERFORM, READ, and SET statements are used.

Building the Program

Project manager's Build function is used to create the executable program.

In the following screen snapshots, the sample program was installed to C:\NetCOBOL. Your installation folder may be different.

  1. The project manager is started.

  2. The project file "MTHAPL.PRJ" is opened.

  3. The project file is selected, and "Compiler options" is selected from "Project"-"Options" menu.

    The "Compiler options" dialog is displayed.

  4. Compiler option THREAD(MULTI), SHREXT and ALPHAL(WORD) are specified.

    After confirming the information, click the OK button.

    You are now returned to the Project Manager window.

  5. "Build" is selected from Project Manager's "Project" menu.

    (Prior to executing the application, please confirm that all the DLL’s in the application have been built correctly.)

  6. The project file "ISAPIAPL.PRJ" is opened

  7. The compiler option dialog is displayed as in step 3 above, showing that the compiler options THREAD(MULTI), SHREXT, and ALPHAL(WORD) are specified.

    Modify the folder name of the library file specified in the compiler option LIB.

    Click the OK button.

    You are now returned to the Project Manager window.

  8. "Build" is selected from Project Manager's "Project" menu.

Executing the Program

It is assumed that the domain-name and virtual directory name are registered in IIS (Internet Information Services) as "user" and "sample21" respectively.

This example presumes that Microsoft Internet Explorer is being used.

  1. The authentication service begins.

    The following information is set in URL.

    Address │ http://user/sample21/admin.html

    The administrator menu screen is displayed. Click on the “Set Starting Business” hyperlink.

    When clicked, the authentication service begins. Please do so before starting the authentication service.

  2. The authentication service is started.

    The following information is set in the URL and the "Execute" key is pushed.

    Address │ http://user/sample21/Auth.html

    The authentication service screen is displayed. After the screen is displayed, input a User ID and password, then click the "OK" button.

    Valid User ID’s are USER0001 to USER0030. The password is the same as the User ID.

    When the OK button is clicked, the authentication success screen is displayed.

    If the User ID and/or password are invalid, an authentication failure screen is displayed.

  3. The authentication service is ended.

    Input following information in the URL and press the "Execute" key.

    Address │ http://user/sample21/admin.html

    Because the administrator menu screen is displayed, "Set ending business" is clicked.