Codota Logo
ThreadPoolExecutor$Worker
Code IndexAdd Codota to your IDE (free)

How to use
ThreadPoolExecutor$Worker
in
edu.emory.mathcs.backport.java.util.concurrent

Best Java code snippets using edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker (Showing top 15 results out of 315)

  • Common ways to obtain ThreadPoolExecutor$Worker
private void myMethod () {
ThreadPoolExecutor$Worker t =
  • Codota IconIterator iterator;(Worker) iterator.next()
  • Codota IconThreadPoolExecutor firstTask;new Worker(firstTask)
  • Smart code suggestions by Codota
}
origin: backport-util-concurrent/backport-util-concurrent

/**
 * Returns the approximate number of threads that are actively
 * executing tasks.
 *
 * @return the number of threads
 */
public int getActiveCount() {
  final ReentrantLock mainLock = this.mainLock;
  mainLock.lock();
  try {
    int n = 0;
    for (Iterator itr = workers.iterator(); itr.hasNext();) {
      Worker w = (Worker)itr.next();
      if (w.isLocked())
        ++n;
    }
    return n;
  } finally {
    mainLock.unlock();
  }
}
origin: backport-util-concurrent/backport-util-concurrent

Worker w = (Worker)it.next();
Thread t = w.thread;
if (!t.isInterrupted() && w.tryLock()) {
  try {
    t.interrupt();
  } catch (SecurityException ignore) {
  } finally {
    w.unlock();
origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

/**
 * Returns the approximate total number of tasks that have ever been
 * scheduled for execution. Because the states of tasks and
 * threads may change dynamically during computation, the returned
 * value is only an approximation.
 *
 * @return the number of tasks
 */
public long getTaskCount() {
  final ReentrantLock mainLock = this.mainLock;
  mainLock.lock();
  try {
    long n = completedTaskCount;
    for (Iterator itr = workers.iterator(); itr.hasNext();) {
      Worker w = (Worker)itr.next();
      n += w.completedTasks;
      if (w.isLocked())
        ++n;
    }
    return n + workQueue.size();
  } finally {
    mainLock.unlock();
  }
}
origin: backport-util-concurrent/backport-util-concurrent-java12

/**
 * Returns the approximate total number of tasks that have ever been
 * scheduled for execution. Because the states of tasks and
 * threads may change dynamically during computation, the returned
 * value is only an approximation.
 *
 * @return the number of tasks
 */
public long getTaskCount() {
  final ReentrantLock mainLock = this.mainLock;
  mainLock.lock();
  try {
    long n = completedTaskCount;
    for (Iterator itr = workers.iterator(); itr.hasNext();) {
      Worker w = (Worker)itr.next();
      n += w.completedTasks;
      if (w.isLocked())
        ++n;
    }
    return n + workQueue.size();
  } finally {
    mainLock.unlock();
  }
}
origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

/**
 * Returns the approximate number of threads that are actively
 * executing tasks.
 *
 * @return the number of threads
 */
public int getActiveCount() {
  final ReentrantLock mainLock = this.mainLock;
  mainLock.lock();
  try {
    int n = 0;
    for (Iterator itr = workers.iterator(); itr.hasNext();) {
      Worker w = (Worker)itr.next();
      if (w.isLocked())
        ++n;
    }
    return n;
  } finally {
    mainLock.unlock();
  }
}
origin: backport-util-concurrent/backport-util-concurrent-java12

Worker w = (Worker)it.next();
Thread t = w.thread;
if (!t.isInterrupted() && w.tryLock()) {
  try {
    t.interrupt();
  } catch (SecurityException ignore) {
  } finally {
    w.unlock();
origin: backport-util-concurrent/backport-util-concurrent

try {
  while (task != null || (task = getTask()) != null) {
    w.lock();
    clearInterruptsForTaskRun();
    try {
      task = null;
      w.completedTasks++;
      w.unlock();
origin: backport-util-concurrent/backport-util-concurrent-java12

try {
  while (task != null || (task = getTask()) != null) {
    w.lock();
    clearInterruptsForTaskRun();
    try {
      task = null;
      w.completedTasks++;
      w.unlock();
origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

try {
  while (task != null || (task = getTask()) != null) {
    w.lock();
    clearInterruptsForTaskRun();
    try {
      task = null;
      w.completedTasks++;
      w.unlock();
origin: backport-util-concurrent/backport-util-concurrent

Worker w = new Worker(firstTask);
Thread t = w.thread;
origin: backport-util-concurrent/backport-util-concurrent-java12

/**
 * Returns the approximate number of threads that are actively
 * executing tasks.
 *
 * @return the number of threads
 */
public int getActiveCount() {
  final ReentrantLock mainLock = this.mainLock;
  mainLock.lock();
  try {
    int n = 0;
    for (Iterator itr = workers.iterator(); itr.hasNext();) {
      Worker w = (Worker)itr.next();
      if (w.isLocked())
        ++n;
    }
    return n;
  } finally {
    mainLock.unlock();
  }
}
origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

Worker w = new Worker(firstTask);
Thread t = w.thread;
origin: backport-util-concurrent/backport-util-concurrent

/**
 * Returns the approximate total number of tasks that have ever been
 * scheduled for execution. Because the states of tasks and
 * threads may change dynamically during computation, the returned
 * value is only an approximation.
 *
 * @return the number of tasks
 */
public long getTaskCount() {
  final ReentrantLock mainLock = this.mainLock;
  mainLock.lock();
  try {
    long n = completedTaskCount;
    for (Iterator itr = workers.iterator(); itr.hasNext();) {
      Worker w = (Worker)itr.next();
      n += w.completedTasks;
      if (w.isLocked())
        ++n;
    }
    return n + workQueue.size();
  } finally {
    mainLock.unlock();
  }
}
origin: backport-util-concurrent/backport-util-concurrent-java12

Worker w = new Worker(firstTask);
Thread t = w.thread;
origin: edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport

Worker w = (Worker)it.next();
Thread t = w.thread;
if (!t.isInterrupted() && w.tryLock()) {
  try {
    t.interrupt();
  } catch (SecurityException ignore) {
  } finally {
    w.unlock();
edu.emory.mathcs.backport.java.util.concurrentThreadPoolExecutor$Worker

Javadoc

Class Worker mainly maintains interrupt control state for threads running tasks, along with other minor bookkeeping. This class opportunistically extends ReentrantLock to simplify acquiring and releasing a lock surrounding each task execution. This protects against interrupts that are intended to wake up a worker thread waiting for a task from instead interrupting a task being run.

Most used methods

  • <init>
    Creates with given first task and thread from ThreadFactory.
  • isLocked
  • lock
  • tryLock
  • unlock

Popular in Java

  • Making http requests using okhttp
  • startActivity (Activity)
  • getApplicationContext (Context)
  • runOnUiThread (Activity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Collectors (java.util.stream)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now