SHARING Option
You can use the compiler control option SHARING to specify whether one or many processes can link to the same instance of a connection library. The SHARING option has the same range of values for connection libraries that it does for server libraries. The meanings are also roughly the same.
Responding Library Determines Sharing
When one connection library links to another, the SHARING option of the responding library determines whether a new library instance is created.
Same Sharing for All Libraries in a Program
Because the SHARING option can be specified only once in a program (at the start), all the connection libraries in a single program use the same SHARING value.
The following paragraphs explain the special implications that each SHARING value has for a connection library.
SHARING = PRIVATE
The system initiates a separate instance of the connection library program each time a process attempts to link to any connection library in the program. Even if two processes link to different connection libraries in the PRIVATE library program, the system still initiates two separate instances of the PRIVATE library program. As a result, processes linking to a connection library in the PRIVATE library program will never use more than the first connection specified for that library
However, the PRIVATE library program could itself use repeated LINKLIBRARY functions to create multiple connections between a connection library and other libraries.
The PRIVATE sharing option is less useful for connection libraries than it is for server libraries, because SHAREDBYALL connection libraries can use connection objects to store data that is different for each user. Refer to Connection Objects in Connection Libraries.
SHARING = SHAREDBYALL
All processes that link to the library program share the same instance of the library. If one such process changes the value of a global object in the library, the next process that interrogates the global object receives the changed value. However, if one such process changes the value of a connection object in the library, the change is visible only to the process that is linked through that connection. The SHAREDBYALL option is the SHARING option typically used for connection library programs
The SHAREDBYALL option should not typically be used for connection libraries that have the SINGLE keyword. The SHAREDBYALL option ensures that all processes that link to the library will access the same library instance, but the SINGLE keyword ensures that only one connection is available for linking to that library instance. Therefore, only one process at a time can be linked to the library. If any other process attempts to link to the connection library when the library is already in use, the linkage attempt fails immediately and returns an error result.
SHARING = SHAREDBYRUNUNIT
This value cannot be used for connection libraries. If a program has SHARING = SHAREDBYRUNUNIT, then any attempt to perform a READYCL function for a connection library declared in that program results in a runtime error.
SHARING = DONTCARE
This option is a nonpreferred synonym for SHAREDBYALL
Default SHARING Value
If a connection library program does not include the SHARING compiler control option, then the compiler assigns a default SHARING option of SHAREDBYALL to the program.

