<commit_before>/**
 * Copyright (C) 2009 - 2009 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.util;

/**
 * Utility methods for working with threads.
 *
 * @author kirk
 */
public final class ThreadUtil {
  private ThreadUtil() {
  }
  
  /**
   * Attempt to join the thread specified safely.
   *  
   * @param t The thread to join.
   * @return {@code true} if the join succeeded, or {@code false} if
   *         we went past the timeout.
   */
  public static boolean safeJoin(Thread t, long msTimeout) {
    try {
      t.join(msTimeout);
    } catch (InterruptedException e) {
      // Clear the interrupted state.<commit_msg>Have safeJoin() check for already being terminated before attempting to join.<commit_after>/**
 * Copyright (C) 2009 - 2009 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.util;

/**
 * Utility methods for working with threads.
 *
 * @author kirk
 */
public final class ThreadUtil {
  private ThreadUtil() {
  }
  
  /**
   * Attempt to join the thread specified safely.
   *  
   * @param t The thread to join.
   * @return {@code true} if the join succeeded, or {@code false} if
   *         we went past the timeout.
   */
  public static boolean safeJoin(Thread t, long msTimeout) {
    if(!t.isAlive()) {
      return true;
    }
    try {
      t.join(msTimeout);
    } catch (InterruptedException e) {
      // Clear the interrupted state.
{'fraction_non_alphanumeric': 0.10699588477366255, 'fraction_numerical': 0.010973936899862825, 'mean_word_length': 2.629353233830846, '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': '6800629', 'n_tokens_mistral': 444, 'n_tokens_neox': 424, 'n_words': 160}