Generating Thread Dump on Sun JDK with Timestamp
You can use VisualVM utility provided in JDK 6.0. You can connect to your Java5 application using visualvm and can get/compare thread dump, memory dump etc.
Thread dump in a separate file with tomcat?
Thread-dump is always written to stdout and Tomcat redirects stdout to catalina.out by default. You can change where it redirects the stdout to but you can't separate thread-dump from other things written to stdout.
Sounds like you have other debug information written to catalina.out. Maybe you can get around this issue by writing all your debug messages to your own log so catalina.out is reserved for thread-dump and a few other things.
See my answer to this question on how to create your own log files,
How to configure logs/catalina.out of tomcat 6 for per-app. (Configure web-app specific log file for sys.out, sys.err)
Thread Dump during Full GC
You can't obtain any detailed information during a GC. You can now obtain the size of the various heaps via jstat but if your full GC is a stop-the-world- collection it means that everything else has stopped.
Additionally if you could obtain this information, it is unlikely to be what you need to know, it is just one random sample so unless there is only one place which is triggering a gc e.g. a call to System.gc(), or only one place allocating, it won't be so useful.
If you want to know where System.gc() is being triggered you can use instrumentation (or a modified System
class) to do a stack trace where it is explicitly called. I have done this before and found it was the DGC. https://plumbr.eu/blog/garbage-collection/rmi-enforcing-full-gc-to-run-hourly
If you want to know where the highest allocation rate is, I suggest using a memory profiler. That is what the tools is for. It can show you stack traces of where the most/largest objects are being created.
Java thread dump: `WAITING (on object monitor)` line not followed by `waiting on 0x1234` line
It seems that I saw a problem where there is actually no problem.
Related Topics
Exception in Initializer Error in Java When Using Netbeans
Can't a Swing Component Be Added to Multiple Containers
Difference Between Oracle Jdbc Driver Classes
Problems with Newline in Graphics2D.Drawstring
Check If a File Is Locked in Java
What Does This Thread Join Code Mean
Why Isn't a Qualified Static Final Variable Allowed in a Static Initialization Block
Jackson - Serialization of Entities with Birectional Relationships (Avoiding Cycles)
Cannot Create Jdbc Driver of Class ' ' for Connect Url 'Null':I Do Not Understand This Exception
Spring Data: Override Save Method
How Does the Bitwise & (And) Work in Java