Example of code causing an exclusive deadlock

The following sequence of EXEC commands would cause an exclusive control deadlock to occur.

The first command causes shared control to be acquired:
       EXEC CICS STARTBR
            FILE(myfile)
            RIDFLD(rid-area)
This causes no problems. The next command at first acquires shared control while the record is read into input-area. When an attempt is subsequently made to get exclusive control, deadlock occurs because the task that wants exclusive control is also the task that is preventing it from being acquired.
       EXEC CICS READ
            FILE(myfile)
            INTO(input-area)
            RIDFLD(rid-area)
            UPDATE
The following sequence of commands would not cause deadlock to occur, because the transaction relinquishes its shared control of the CI by ending the browse before attempting to get exclusive control of it.
The first command causes shared control to be acquired:
       EXEC CICS STARTBR
            FILE(myfile)
            RIDFLD(rid-area)
The next command causes shared control to be relinquished:
       EXEC CICS ENDBR
            FILE(myfile)
The next command initially causes shared control to be acquired. The record is read into input-area, and then exclusive control is acquired in place of shared control.
       EXEC CICS READ
            FILE(myfile)
            INTO(input-area)
            RIDFLD(rid-area)
            UPDATE
The transaction now resumes. Exclusive control is relinquished following the next REWRITE or UNLOCK command on file myfile.