Considerations for a shared JVM

When you are developing Java™ applications to run in CICS®, be aware that changes to shared resources within the JVM might be seen by all running applications and threads. Ensure that your applications do not leave the JVM in an unexpected state that other applications might rely on.

The following points are important considerations to think about:
  • If your application resets the default time zone, other applications that use the same JVM server will use the new default time zone, which might be unexpected.
  • Do not use System.exit() in your applications. Using System.exit() causes both the JVM server and CICS to shut down.
  • Ensure that your applications are Threadsafe. Static variables that are shared between applications need careful review to ensure that there is no cross contamination between applications. A typical pattern to ensure uniqueness, is to use ThreadLocal variables.
  • If objects are referenced by static variables, they are not candidates for garbage collection. In a JVM server, static state persists for all applications until the JVM server is disabled by the system programmer.
  • It is possible to have multiple connections to Db2® from different applications. Therefore, when a task finishes with Db2, it is best practice to close the connection even if that connection is later deleted when the task completes.
  • Sockets created using classes from the java.net package are not CICS domain sockets and cannot be managed or monitored by CICS.