Skip to content
Each UserThreadPoolExecutor is given a maximum number of threads from a shared ThreadPoolExecutor
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
LICENSE
README.md
pom.xml

README.md

UserThreadPoolExecutor

Description

Each UserThreadPoolExecutor is given a maximum number of threads from a shared ThreadPoolExecutor

Each UserThreadPoolExecutor can:

  • submit a task to the shared thread pool executor if its quota is not reached. If its quota is reached, the job is queued (non-consumptive blocking waiting for CPU) Once one of its submitted task is completed, the quota is decremented, allowing another task waiting to be submitted to the ThreadPoolExecutor
  • wait for the remaining tasks to complete

Example

See: UserThreadPoolTest.java:

// submitting a number of 10 tasks (max per user = 5)
// this thread will block of the 6th task, waiting for a finished task to proceed
for (int i = 0; i < 10; i++) {
    userThreadPoolExecutor.submit(new SampleTask(i+1));
}

// waiting (in this thread) for remaining user tasks to finish
userThreadPoolExecutor.waitForRemainingTasks();

Run a test

mvn clean test
You can’t perform that action at this time.