The CMS algorithm for garbage collection scans heap memory using multiple threads. Similar to the mark and sweep method, it marks objects for removal and then makes a sweep to actually remove those objects. This method of garbage collection is essentially an upgraded mark and sweep method. It was modified to take advantage of faster systems and had performance enhancements.
To manually invoke the CMS garbage collection algorithm for your application, use the following command-line option:
-XX:+UseConcMarkSweepGC
If you want to use the CMS garbage collection algorithm and dictate the number of threads to use, you can use the following command-line option. In the following example, we are telling the Java platform to use the CMS garbage collection algorithm with eight threads:
-XX:ParallelCMSThreads=8