Purging Java tasks
In some circumstances, it can be desirable to terminate tasks running in Java™ without bringing down the whole JVM. Although it is not guaranteed that using SET TASK PURGE terminates the Java workload, it can be effective in some situations. Using SET TASK PURGE on tasks running Java should be used with caution and with an understanding of the running workload to avoid potentially disruptive effects.
About this task
Prior to CICS® TS 5.4, TASK PURGE of individual tasks was not allowed if the task was running Java. PURGING of Java tasks is now enabled, but you should be aware that the Java programming language and JVM are not designed to allow threads to be stopped without co-operative interrupt processing. CICS employs stronger measures to forcibly terminate a thread and if effective terminates the Java program with an error. In particular the Thread.stop() method is used to inject a ThreadDeath error directly into the application. As a result the Java stack is immediately unwound and locks are released ahead of normal application flow. This action has the potential to leave shared Java objects and data in an inconsistent state. You should carefully assess the impact on any applications still running.
In an ideal scenario, all Java code would be designed to respect interrupts. In practice, it is hard to achieve, especially when third-party components are used. The following information gives a useful understanding why terminating threads in the JVM is difficult to achieve, and what patterns a Java programmer should follow to make their application interruptible: Java Thread Primitive Deprecation.