Tabnine Logo
java.util.concurrent
Code IndexAdd Tabnine to your IDE (free)

How to use java.util.concurrent

Best Java code snippets using java.util.concurrent (Showing top 20 results out of 62,496)

origin: square/okhttp

/**
 * For testing: force this web socket to release its threads.
 */
void tearDown() throws InterruptedException {
 if (cancelFuture != null) {
  cancelFuture.cancel(false);
 }
 executor.shutdown();
 executor.awaitTermination(10, TimeUnit.SECONDS);
}
origin: iluwatar/java-design-patterns

 /**
  * Stops the pool of workers.
  * 
  * @throws InterruptedException if interrupted while stopping pool of workers.
  */
 @Override
 public void stop() throws InterruptedException {
  executorService.shutdown();
  executorService.awaitTermination(4, TimeUnit.SECONDS);
 }
}
origin: iluwatar/java-design-patterns

/**
 * Creates a pooled dispatcher with tunable pool size.
 * 
 * @param poolSize number of pooled threads
 */
public ThreadPoolDispatcher(int poolSize) {
 this.executorService = Executors.newFixedThreadPool(poolSize);
}
origin: google/guava

 @Override
 public Void call() throws Exception {
  startLatch.countDown();
  startLatch.await();
  callable.call();
  doneLatch.countDown();
  return null;
 }
});
origin: ReactiveX/RxJava

  @Override
  public Integer call() throws Exception {
    cdl1.countDown();
    cdl2.await(5, TimeUnit.SECONDS);
    return 1;
  }
}).subscribeOn(Schedulers.single()).test();
origin: ReactiveX/RxJava

@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
  observerReceivedTwo.countDown();
  return null;
}
origin: google/guava

public static List<BlockingQueue<Object>> blockingQueues() {
 return ImmutableList.<BlockingQueue<Object>>of(
   new LinkedBlockingQueue<Object>(),
   new LinkedBlockingQueue<Object>(10),
   new SynchronousQueue<Object>(),
   new ArrayBlockingQueue<Object>(10),
   new LinkedBlockingDeque<Object>(),
   new LinkedBlockingDeque<Object>(10),
   new PriorityBlockingQueue<Object>(10, Ordering.arbitrary()));
}
origin: ReactiveX/RxJava

  @Override
  public void accept(Integer v) throws Exception {
    if (!cdl.await(5, TimeUnit.SECONDS)) {
      throw new TimeoutException();
    }
  }
})
origin: ReactiveX/RxJava

  public Thread getThread() throws InterruptedException {
    latch.await();
    return thread;
  }
}
origin: ReactiveX/RxJava

static Future<Integer> emptyFuture() {
  final ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
  return exec.schedule(new Callable<Integer>() {
    @Override
    public Integer call() throws Exception {
      exec.shutdown();
      return null;
    }
  }, 200, TimeUnit.MILLISECONDS);
}
origin: ReactiveX/RxJava

  @Override
  public Scheduler apply(Callable<Scheduler> schedulerCallable) throws Exception {
    return schedulerCallable.call();
  }
};
origin: spring-projects/spring-framework

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
  boolean result = this.delegate.cancel(mayInterruptIfRunning);
  super.cancel(mayInterruptIfRunning);
  return result;
}
origin: ReactiveX/RxJava

  @Override
  public Integer call() throws Exception {
    exec.shutdown();
    return null;
  }
}, 200, TimeUnit.MILLISECONDS);
origin: ReactiveX/RxJava

/**
 * Returns true if TestObserver/TestSubscriber received any onError or onComplete events.
 * @return true if TestObserver/TestSubscriber received any onError or onComplete events
 */
public final boolean isTerminated() {
  return done.getCount() == 0;
}
origin: spring-projects/spring-framework

@Override
public void shutdownExecutor() {
  List<Runnable> remainingTasks = concurrentExecutor.shutdownNow();
  for (Runnable task : remainingTasks) {
    if (task instanceof RunnableFuture) {
      ((RunnableFuture<?>) task).cancel(true);
    }
  }
}
origin: ReactiveX/RxJava

  @Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};
origin: ReactiveX/RxJava

  @Override
  public void run() {
    timedRunnable.disposed = true;
    queue.remove(timedRunnable);
  }
}
origin: ReactiveX/RxJava

  @Override
  public void accept(Long aLong) {
      // Ensure there is at least some onNext events before un-subscription happens
      onNextLatch.countDown();
  }
})
origin: ReactiveX/RxJava

  @Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    interrupted[0] = mayInterruptIfRunning;
    return super.cancel(mayInterruptIfRunning);
  }
};
origin: ReactiveX/RxJava

  @Override
  public void accept(Long aLong) {
      // Ensure there is at least some onNext events before un-subscription happens
      onNextLatch.countDown();
  }
})
java.util.concurrent

Most used classes

  • AtomicInteger
  • ExecutorService
  • Executors
  • ConcurrentHashMap
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • TimeUnit
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • AtomicLong,
  • Future,
  • ConcurrentMap,
  • AtomicReference,
  • CountDownLatch,
  • ScheduledExecutorService,
  • Lock,
  • BlockingQueue,
  • LinkedBlockingQueue,
  • ExecutionException,
  • Callable,
  • ThreadPoolExecutor,
  • CompletableFuture,
  • ReentrantLock
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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