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

ch.qos.logback.core.util.InterruptUtil Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version
package ch.qos.logback.core.util;

import ch.qos.logback.core.Context;
import ch.qos.logback.core.spi.ContextAwareBase;

/**
 *  Allows masking of interrupt flag if previously the flag is already set. Does nothing otherwise.
 *
 *  Typical use:
 *
 *  
 *  InterruptUtil interruptUtil = new InterruptUtil(context);
 *
 *  try {
 *    interruptUtil.maskInterruptFlag();
 *    someOtherThread.join(delay);
 *  } catch(InterruptedException e) {
 *    // reachable only if join does not succeed within delay.
 *    // Without the maskInterruptFlag() call, the join() would have returned immediately
 *    // had the current thread been interrupted previously, i.e. before entering the above block
 *  } finally {
 *    interruptUtil.unmaskInterruptFlag();
 *  }
 *  
* @author Ceki Gulcu * @since 1.2.2 * * @deprecated This internal logback API is not supported by AEM as a Cloud Service. */ @Deprecated(since = "2022-01-27") public class InterruptUtil extends ContextAwareBase { final boolean previouslyInterrupted; public InterruptUtil(Context context) { super(); setContext(context); previouslyInterrupted = Thread.currentThread().isInterrupted(); } public void maskInterruptFlag() { if (previouslyInterrupted) { Thread.interrupted(); } } public void unmaskInterruptFlag() { if (previouslyInterrupted) { try { Thread.currentThread().interrupt(); } catch (SecurityException se) { addError("Failed to intrreupt current thread", se); } } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy