Monitoring Garbage Collector's time stamps using the GarbageCollectorMXBean

This post shows how to print to the GC log a summary of minor and full garbage collections:
It's done by creating a thread that uses the GarbageCollectorMXBean.
The result of this thread is printing to the GC log (each pre-defined time) a summary of the minor and full collections that were performed in that time.
For example, the following line:
2007-09-28 17:03:59,037 [84.80] Minor GC x 6, 22 millisecs
represents 6 minor collections that took 22 milliseconds.