CICS® provides the JVM server environment for running threadsafe Java applications. Applications that are not threadsafe cannot use the JVM server.
The JVM server is a runtime environment that can run tasks in a single JVM. This environment reduces the amount of virtual storage required for each Java task, and allows CICS to run many tasks concurrently.
CICS tasks run in parallel as threads in the same JVM server process. The JVM is shared by all CICS tasks, which might be running multiple applications concurrently. All static data and static classes are also shared. So to use a JVM server in CICS, a Java application must be threadsafe. Each thread runs under a T8 TCB and can access CICS services using the JCICS API.
You can write application code to start a new thread or call a library that starts a thread. However, these threads cannot access CICS services. Any attempt to access CICS services from an application-spawned thread results in a Java bm.exception. If you want to create threads in your application, ensure that they do not run beyond the lifetime of the CICS task that runs the application. When the system programmer disables the JVM server, CICS waits for all current threads running on T8 TCBs to finish in the JVM. However, any threads created by an application itself are terminated.
Because static data is shared by all threads running in the JVM server, you can create OSGi bundle activator classes to initialize static data and leave it in the correct state when the JVM shuts down. A JVM server runs until the system programmer disables it, for example to add an application or fix a problem. By providing bundle activator classes, you can ensure that the state is correctly set for your applications. CICS has a timeout that specifies how long to wait for these classes to complete before continuing to start or stop the JVM server. You cannot use JCICS in startup and termination classes.
Do not use the System.exit() method in your applications. This method causes both the JVM server and CICS to shut down, affecting the state and availability of your applications.