Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.metrics.util;
 
 
 import java.util.Set;

A com.yammer.metrics.core.HealthCheck implementation which returns a list of deadlocked threads, if any.
public class DeadlockHealthCheck extends HealthCheck {
    private final VirtualMachineMetrics vm;

    
        super("deadlocks");
        this. = vm;
    }

    
Creates a new DeadlockHealthCheck.
    @SuppressWarnings("UnusedDeclaration")
    public DeadlockHealthCheck() {
        this(VirtualMachineMetrics.getInstance());
    }
    @Override
    protected Result check() throws Exception {
        final Set<Stringthreads = .deadlockedThreads();
        if (threads.isEmpty()) {
            return Result.healthy();
        }
        final StringBuilder builder = new StringBuilder("Deadlocked threads detected:\n");
        for (String thread : threads) {
            builder.append(thread).append('\n');
        }
        return Result.unhealthy(builder.toString());
    }
New to GrepCode? Check out our FAQ X