What is the difference between a profiler and a debugger in Java?
A profiler tracks memory usage, whereas a debugger helps find runtime exceptions and errors.
That's partially correct. While it's true that a debugger helps with finding errors, a profiler also tracks CPU usage, thread activity, and more.
Can you explain how a profiler tracks CPU usage and thread activity during execution?