Class ConcurrencyUtil

java.lang.Object
org.eclipse.net4j.util.concurrent.ConcurrencyUtil

public final class ConcurrencyUtil extends Object
Author:
Eike Stepper
  • Method Details

    • sleep

      public static void sleep(long millis)
    • sleep

      public static void sleep(long millis, int nanos)
    • getExecutorService

      public static ExecutorService getExecutorService(IManagedContainer container)
      Since:
      3.5
    • getExecutorService

      public static ExecutorService getExecutorService(Object object)
      Since:
      3.6
    • execute

      public static void execute(Object executor, Runnable runnable)
      Since:
      3.6
    • setThreadName

      public static void setThreadName(Thread thread, String name)
      Since:
      3.8
    • setThreadName

      public static void setThreadName(String name)
      Since:
      3.9
    • log

      public static void log(String msg)
      Since:
      3.9
    • checkCancelation

      public static void checkCancelation(IProgressMonitor monitor) throws OperationCanceledException
      Throws:
      OperationCanceledException
      Since:
      3.13
    • restoreInterrupt

      public static void restoreInterrupt(Throwable ex)
      Restores the interrupt status of the current thread when the directly caught exception is an InterruptedException.

      Interruptible operations such as Thread.sleep(long), Object.wait(), Thread.join(), CountDownLatch.await(), and interruptible queue or lock operations clear the current thread's interrupt status before throwing InterruptedException. This helper is intended for a broader catch boundary that cannot propagate that checked exception and instead translates it or otherwise terminates the current operation, when the surrounding thread-ownership and cancellation policy requires the status to remain observable.

      Callers must not use this as a blanket action for every broad catch, as a substitute for propagating InterruptedException, or without analyzing continuing loops, retry logic, worker lifecycle code, ordinary-result translations, and intentional interrupt-consumption policies. Those contexts may require a different policy, because retaining the status can change subsequent waits, retries, shutdown behavior, or worker termination.

      Only the directly caught value is inspected. Causes are deliberately not traversed: a wrapper that merely contains an InterruptedException does not establish that this catch consumed the current thread's interrupt status, and restoring from a nested historical cause could spuriously interrupt unrelated execution.

      For a non-InterruptedException value this method does nothing. For an InterruptedException it sets the current thread's interrupt status and otherwise leaves the supplied exception untouched. It does not throw, wrap, log, or inspect causes.

      Parameters:
      ex - the exception directly caught by the caller
      Since:
      3.31