Example usage for java.lang.management ThreadMXBean isThreadContentionMonitoringSupported

List of usage examples for java.lang.management ThreadMXBean isThreadContentionMonitoringSupported

Introduction

In this page you can find the example usage for java.lang.management ThreadMXBean isThreadContentionMonitoringSupported.

Prototype

public boolean isThreadContentionMonitoringSupported();

Source Link

Document

Tests if the Java virtual machine supports thread contention monitoring.

Usage

From source file:io.pcp.parfait.benchmark.StandardMetricThroughPutBenchmark.java

public static void main(String[] args) throws InterruptedException, UnknownHostException {
    int numThreads = args.length < 1 ? Runtime.getRuntime().availableProcessors() : Integer.valueOf(args[0]);
    int numCounters = 1000;
    int iterations = 10000;

    ReportHelper.environmentReportHeader();
    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
    System.out.printf("Thread Contention Supported: %s, Enabled by default: %s\n",
            threadMXBean.isThreadContentionMonitoringSupported(),
            threadMXBean.isThreadContentionMonitoringEnabled());
    System.out.printf("numThreads: %d, numCounters=%d, iterations=%d\n", numThreads, numCounters, iterations);

    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, false, false).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, false).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, true).runBenchmark();

    // now do it all again reverse, in case there's any JVM warmup issues unfairly treating the first/last runs
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, true).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, true, false).runBenchmark();
    new StandardMetricThroughPutBenchmark(numThreads, numCounters, iterations, false, false).runBenchmark();
}