Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
add method to get remaining ThreadPoolTaskExecutor's queue capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Tobayiwa committed Jan 19, 2024
1 parent bd2512e commit 6a75b3b
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,19 @@ public void shutdown() {
messageProcessingExecutor.getThreadPoolExecutor().awaitTermination(10, TimeUnit.SECONDS);
}
}
/**
* Returns the number of elements that the {@link #messageProcessingExecutor} can accept
* <p>
* This method should only be used in a single threaded environment, since it is possible that
* in a multi-threaded environment the number of free slots changes between the call to this method
*
* @return Remaining queue capacity
*/
public int getQueueCapacity() {
return messageProcessingExecutor
.getThreadPoolExecutor()
.getQueue()
.remainingCapacity();
}

}

0 comments on commit 6a75b3b

Please sign in to comment.