Apparatus, methods, and computer program products are disclosed for a
process of terminating a thread in a clean, certain, and forcible manner. A thread
is forcibly terminated in such a manner that data structures in the system are
not left in an inconsistent state and the overall system status is not damaged.
The methods and systems described are for terminating a thread in a computer language
execution environment. Methods are implemented in an interpretive loop executing
in a language that is interpreted and in runtime support libraries in a language
that are not interpreted. A method of forcibly terminating a thread in a computer
language execution environment is described. A thread receives a terminate thread
command. The thread has associated with it a termination flag, a value of the termination
flag being immutable once set, and one or more monitors. The termination flag is
then set for the thread. An exception is then propagated in the execution environment
thereby indicating termination of the thread. The exception handler and the finally
clause of the thread is ignored during thread termination. The monitors associated
with the thread are then exited.