Skip to content

heavyplayer/ElasticThreadPoolExecutor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ElasticThreadPoolExecutor

A more dynamic ThreadPoolExecutor implementation.

Behavior

Exactly like the regular ThreadPoolExecutor, with one small but very important difference: instead of only spawning more threads when the working queue is full, this implementation spawns more threads when all core threads are occupied (up to the maximum threads you specify).

Example: You specify that the core pool size is 2, and that the maximum size is 4.

Action Core threads Working threads Queue size
Submit long task 2 1 0
Submit long task 2 2 0
Submit long task 3 3 0
Submit long task 4 4 0
Submit long task 4 4 1
Submit long task 4 4 2
Wait for tasks to complete and for the specified thread timeout
Nothing 2 0 0

That's it. If you still have doubts about how it works, don't forget to check the tests.


Copyright © 2010 Heavy Player, released under the MIT license

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages