congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Threads
Code IndexAdd Tabnine to your IDE (free)

How to use
Threads
in
com.obsidiandynamics.threads

Best Java code snippets using com.obsidiandynamics.threads.Threads (Showing top 6 results out of 315)

origin: com.obsidiandynamics.fulcrum/fulcrum-threads

 @Override
 public void run() {
  Threads.await(barrier);
  if (latch != null) Threads.await(latch);
 }
}
origin: com.obsidiandynamics.fulcrum/fulcrum-threads

public static boolean await(CountDownLatch latch) {
 return runUninterruptedly(latch::await);
}

origin: com.obsidiandynamics.fulcrum/fulcrum-retry

 public <T, X extends Throwable> T run(CheckedSupplier<? extends T, X> operation) throws X {
  for (int attempt = 0;; attempt++) {
   try {
    return operation.get();
   } catch (Throwable e) {
    if (exceptionMatcher.test(e)) {
     if (attempt == attempts - 1) {
      final String faultMessage = String.format("Fault (attempt #%,d of %,d): aborting", attempt + 1, attempts);
      errorHandler.onException(faultMessage, e);
      throw e;
     } else {
      final String retryMessage = String.format("Fault (attempt #%,d of %,d): retrying in %,d ms", 
                           attempt + 1, attempts, backoffMillis);
      faultHandler.onException(retryMessage, e);
      if (! Threads.sleep(backoffMillis)) {
       final String interruptMessage = String.format("Fault (attempt #%,d of %,d): aborting due to interrupt", 
                              attempt + 1, attempts);
       errorHandler.onException(interruptMessage, e);
       throw e;
      }
     }
    } else {
     throw e;
    }
   }
  }
 }
}
origin: com.obsidiandynamics.fulcrum/fulcrum-threads

public static boolean sleep(long millis) {
 if (millis > 0) {
  return runUninterruptedly(() -> Thread.sleep(millis));
 } else {
  return ! Thread.currentThread().isInterrupted();
 }
}
origin: com.obsidiandynamics.fulcrum/fulcrum-threads

private static Parallel create(int threads, boolean blocking, IntConsumer r) {
 final CountDownLatch latch = blocking ? new CountDownLatch(threads) : null;
 final CyclicBarrier barrier = new CyclicBarrier(threads + 1);
 final String threadNameFormat = "ParRunner-%0" + numDigits(threads) + "d";
 for (int i = 0; i < threads; i++) {
  final int _i = i;
  final Thread t = new Thread(() ->  {
   Threads.await(barrier);
   try {
    r.accept(_i);
   } finally {
    if (latch != null) latch.countDown();
   }
  }, String.format(threadNameFormat, i));
  t.start();
 }
 return new Parallel(latch, barrier);
}

origin: com.obsidiandynamics.fulcrum/fulcrum-threads

public static boolean await(CyclicBarrier barrier) {
 return runUninterruptedly(() -> {
  try {
   barrier.await();
  } catch (BrokenBarrierException e) {
   throw new RuntimeBrokenBarrierException(e);
  }
 });
}
com.obsidiandynamics.threadsThreads

Most used methods

  • await
  • runUninterruptedly
  • sleep

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now