Skip to main content

I would like to place a thread lock around the code below but I'm not sure what the syntax would be in Visual COBOL. Can you help me with the syntax?

           IF WS-COMM-FROM-PROGRAM > SPACES
             ??Lock
             PERFORM VARYING WS-PREV-PROG-ENTRY
               FROM 1 BY 1 UNTIL WS-PREV-PROG-ENTRY > NAV-MAX-ENTRIES
                  IF NAV-PROGRAM-ID (WS-PREV-PROG-ENTRY) =
                     WS-COMM-FROM-PROGRAM
                     MOVE SPACES TO WS-COMM-FROM-PROGRAM
                     EXIT PERFORM
                  END-IF
             END-PERFORM
             ??End Lock        
           END-IF.

I would like to place a thread lock around the code below but I'm not sure what the syntax would be in Visual COBOL. Can you help me with the syntax?

           IF WS-COMM-FROM-PROGRAM > SPACES
             ??Lock
             PERFORM VARYING WS-PREV-PROG-ENTRY
               FROM 1 BY 1 UNTIL WS-PREV-PROG-ENTRY > NAV-MAX-ENTRIES
                  IF NAV-PROGRAM-ID (WS-PREV-PROG-ENTRY) =
                     WS-COMM-FROM-PROGRAM
                     MOVE SPACES TO WS-COMM-FROM-PROGRAM
                     EXIT PERFORM
                  END-IF
             END-PERFORM
             ??End Lock        
           END-IF.

You could use a mutex for this. See:-

documentation.microfocus.com/.../index.jsp

for an example.

Regards

David


I would like to place a thread lock around the code below but I'm not sure what the syntax would be in Visual COBOL. Can you help me with the syntax?

           IF WS-COMM-FROM-PROGRAM > SPACES
             ??Lock
             PERFORM VARYING WS-PREV-PROG-ENTRY
               FROM 1 BY 1 UNTIL WS-PREV-PROG-ENTRY > NAV-MAX-ENTRIES
                  IF NAV-PROGRAM-ID (WS-PREV-PROG-ENTRY) =
                     WS-COMM-FROM-PROGRAM
                     MOVE SPACES TO WS-COMM-FROM-PROGRAM
                     EXIT PERFORM
                  END-IF
             END-PERFORM
             ??End Lock        
           END-IF.

If this is managed code you could also use the SYNC/END-SYNC statement.

Please see the documentation for an example here:

Thanks