All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mariadb.jdbc.util.ThreadUtils Maven / Gradle / Ivy

The newest version!
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2024 MariaDB Corporation Ab
package org.mariadb.jdbc.util;

import java.util.concurrent.Callable;
import javax.security.auth.Subject;

public class ThreadUtils {
  public static long getId(Thread thread) {
    // must be return thread.threadId() for java 19+,
    // but since we support java 8, cannot be removed for now
    return thread.getId();
  }

  public static void callAs(
      final Subject subject, final Callable> action)
      throws Exception {
    Subject.doAs(subject, action.call());
    // must be for java 18+, but since we support java 8, cannot be removed for now
    // Subject.callAs(subject, action);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy