<commit_before>package com.orbitz.monitoring.lib.timertask;

import com.orbitz.monitoring.api.monitor.EventMonitor;
import com.orbitz.monitoring.api.MonitoringLevel;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;

/**
 * Created by IntelliJ IDEA.
 * User: mkemp
 * Date: Nov 5, 2008
 * Time: 4:51:35 PM
 * To change this template use File | Settings | File Templates.
 */
public class DeadlockDetectionTimerTask implements Runnable {

    public void run() {
        final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
        if(threadBean.isObjectMonitorUsageSupported() && threadBean.isSynchronizerUsageSupported()) {
            if(threadBean.findDeadlockedThreads() != null) {
                final EventMonitor monitor = new EventMonitor("JvmStats", MonitoringLevel.ESSENTIAL);
                monitor.set("type", "Thread.Deadlock");
                monitor.set("count", 1);
                monitor.fire();
            }
        }
    }
}<commit_msg>Switched DeadlockDetectionTimerTask to use Java 1.5 methods<commit_after>package com.orbitz.monitoring.lib.timertask;

import com.orbitz.monitoring.api.monitor.EventMonitor;
import com.orbitz.monitoring.api.MonitoringLevel;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;

/**
 * Created by IntelliJ IDEA.
 * User: mkemp
 * Date: Nov 5, 2008
 * Time: 4:51:35 PM
 * To change this template use File | Settings | File Templates.
 */
public class DeadlockDetectionTimerTask implements Runnable {

    public DeadlockDetectionTimerTask() {
        super();
        final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
        if(threadBean.isThreadContentionMonitoringSupported()) {
            threadBean.setThreadContentionMonitoringEnabled(true);
        }
    }

    public void run() {
        final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
        if(threadBean.isThreadContentionMonitoringEnabled()) {
            if(threadBean.findMonitorDeadlockedThreads() != null) {
                final EventMonitor monitor = new EventMonitor("JvmStats", MonitoringLevel.ESSENTIAL);
                monitor.set("type", "Thread.Deadlock");
                monitor.set("count", 1);
                monitor.fire();
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.10081510081510081, 'fraction_numerical': 0.010296010296010296, 'mean_word_length': 3.1867145421903054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5454844', 'n_tokens_mistral': 672, 'n_tokens_neox': 626, 'n_words': 132}