Multithreading Considerations

When you run in a multithreaded environment, there are many thread-safety issues that you must consider. Before you embark on writing a multithreaded application, you should become familiar with the concepts of multithreading; see information on multithreaded applications at: http://www.ibm.com/systems/infocenter/. You should also become familiar with the common programming errors that are made when coding multithreaded applications; see common multithreaded programming errors at: http://www.ibm.com/systems/infocenter/. Pay special attention to the problems you may encounter using database files, and using commitment control in a multithreaded environment.

One important issue for thread safety is the handling of static storage. There are two ways of ensuring thread-safe handling of static storage in your ILE RPG modules. You can have separate static storage for each thread by specifying THREAD(*CONCURRENT), or you can limit access to the module to only one thread at a time by specifying THREAD(*SERIALIZE). See Multithreaded Applications for a comparison of the two modes of thread-safety.

The remainder of this discussion assumes that you are familiar with these concepts.