A system is disclosed that can determine whether a routine is stalled. The
system does not require the developer of the routine to add code for the
purpose of detecting whether the routine is stalled. Furthermore, the
system can be used to monitor various routines at different levels of
granularity, such as at the thread level, method level, or other levels.
One embodiment of the present invention allows a user to specify a method
and an expected time frame. Code for that method is modified to add
additional code that implements a timing mechanism. The timing mechanism
is used to detect when a thread enters that method and does not return
within an approximation of the expected time frame. Other embodiments are
also within the scope of the present invention.