This may be a problem in Tomcat 5.X too. We are seeing hangs during shutdown of Tomcat. The localhost_log shows a last line of "2005-04-20 06:03:06 StandardWrapper[/TomcatHang:hangServlet]: Waiting for 2 instance(s) to be deallocated". A thread dump shows the main thread waiting at "at org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1074)". There are no HTTP processor threads running - they have all shutdown. Inspecting the code shows unload waiting for the variable countAllocated to go to zero. However, the code that increments and decrements countAllocated for non-single-threaded servlets is not synchronized, so the value will not be correct in some cases. To test this I added synchronized blocks to the increment/decrement code and no longer get hangs.
Created attachment 14769 [details] Thread dump of hung Tomcat
Created attachment 14770 [details] localhost_log
This was fixed almost 3 years ago in 4.1.5 or later.