JSamp is a simple sampling CPU profiler for the JVM, written in Java. It works by periodically taking a snapshot of each thread's stack.
JSamp can be attached/detached arbitrarily to/from a running JVM. It can also be programmatically started/stopped, from within the application itself, when used as a library.
See the Documentation for more details.