java.util.concurrent.ThreadPoolExecutor.getTask()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中java.util.concurrent.ThreadPoolExecutor.getTask()方法的一些代码示例,展示了ThreadPoolExecutor.getTask()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.getTask()方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:getTask

ThreadPoolExecutor.getTask介绍

[英]Performs blocking or timed wait for a task, depending on current configuration settings, or returns null if this worker must exit because of any of: 1. There are more than maximumPoolSize workers (due to a call to setMaximumPoolSize). 2. The pool is stopped. 3. The pool is shutdown and the queue is empty. 4. This worker timed out waiting for a task, and timed-out workers are subject to termination (that is, allowCoreThreadTimeOut || workerCount > corePoolSize) both before and after the timed wait, and if the queue is non-empty, this worker is not the last thread in the pool.
[中]根据当前的配置设置,对任务执行阻塞或定时等待,或者如果由于以下任何原因必须退出此工作进程,则返回null:1。有超过maximumPoolSize的工作人员(由于调用了setMaximumPoolSize)。2.游泳池停了。3.池已关闭,队列为空。4.此工作线程在等待任务时超时,超时工作线程在超时等待前后都会被终止(即allowCoreThreadTimeOut | | workerCount>corePoolSize),如果队列非空,则此工作线程不是池中的最后一个线程。

代码示例

代码示例来源:origin: robovm/robovm

while (task != null || (task = getTask()) != null) {
  w.lock();

代码示例来源:origin: stackoverflow.com

"pool-9-thread-1" #49 prio=5 os_prio=0 tid=0x00007ffd508e8000 nid=0x3a0c runnable [0x00007ffd188b6000]
 java.lang.Thread.State: RUNNABLE
 at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.poll(ScheduledThreadPoolExecutor.java:809)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1066)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)

代码示例来源:origin: stackoverflow.com

"bla" prio=5 tid=7fa2bc16a000 nid=0x10bd53000 runnable [10bd52000]
java.lang.Thread.State: RUNNABLE
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:950)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:680)
Locked ownable synchronizers:
 - None

代码示例来源:origin: stackoverflow.com

"http-nio-8080-exec-13" #42 daemon prio=5 os_prio=0 tid=0x00007f0898005800 nid=0xfb2 waiting on condition [0x00007f0882dec000]
 java.lang.Thread.State: TIMED_WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000000f1694f58> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
 at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:85)
 at org.apache.tomcat.util.threads.TaskQueue.poll(TaskQueue.java:31)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1066)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Thread.java:745)

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

while (task != null || (task = getTask()) != null) {
  w.lock();

代码示例来源:origin: com.bugvm/bugvm-rt

while (task != null || (task = getTask()) != null) {
  w.lock();

代码示例来源:origin: MobiVM/robovm

while (task != null || (task = getTask()) != null) {
  w.lock();

代码示例来源:origin: ibinti/bugvm

while (task != null || (task = getTask()) != null) {
  w.lock();

代码示例来源:origin: com.gluonhq/robovm-rt

while (task != null || (task = getTask()) != null) {
  w.lock();

代码示例来源:origin: FlexoVM/flexovm

while (task != null || (task = getTask()) != null) {
  w.lock();

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

boolean completedAbruptly = true;
try {
  while (task != null || (task = getTask()) != null) {
    w.lock();
    clearInterruptsForTaskRun();

代码示例来源:origin: org.apidesign.bck2brwsr/emul

boolean completedAbruptly = true;
try {
  while (task != null || (task = getTask()) != null) {
    w.lock();
    clearInterruptsForTaskRun();

代码示例来源:origin: jtulach/bck2brwsr

boolean completedAbruptly = true;
try {
  while (task != null || (task = getTask()) != null) {
    w.lock();
    clearInterruptsForTaskRun();

相关文章

ThreadPoolExecutor类方法