A computer program product is provided as a system and associated method
to provide a robust, fail-safe, fast environment for running non-native
language routine programs, such that when the program fails or
terminates, the virtual machine can be restarted without terminating the
operating system process. The system dynamically creates a number of
independent virtual machines to run non-native language routines. Each
virtual machine is created in a process external to the database engine,
in a refreshable native runtime environment inside the process or address
space. If the virtual machine should terminate with an uncaught exception
or error or if it becomes unusable for executing other non-native
language routines, the system recognizes that condition and terminates
the native runtime environment without terminating the process. When a
failed non-native language routine is terminated, the system cleans up
any threads related to the termination of the virtual machine, freeing
memory allocated to the threads and eliminating any possible conflict
between old threads and the next non-native language routine operated by
the virtual machine.