Skip to content

Commit

Permalink
Defer creating new PoolThreadNode until after task is run
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Sep 26, 2024
1 parent 2cc0ffa commit 958a3bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jboss/threads/EnhancedQueueExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1601,8 +1601,6 @@ public void run() {
} else if (node == nextPoolThreadNode) {
// pool thread node was added
final PoolThreadNode newNode = nextPoolThreadNode;
// nextPoolThreadNode has been added to the queue, a new node is required for next time.
nextPoolThreadNode = new PoolThreadNode(currentThread);
// at this point, we are registered into the queue
long start = System.nanoTime();
long elapsed = 0L;
Expand All @@ -1613,6 +1611,8 @@ public void run() {
if (newNode.compareAndSetTask(task, ACCEPTED)) {
// we have a task to run, so run it and then abandon the node
task.run();
// nextPoolThreadNode has been added to the queue, a new node is required for next time.
nextPoolThreadNode = new PoolThreadNode(currentThread);
// rerun outer
continue processingQueue;
}
Expand Down

0 comments on commit 958a3bb

Please sign in to comment.