Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every call to AttemptTimeLimiter.fixedTimeLimit(long, TimeUnit) creates a new CachedThreadPool #17

Closed
rhuffman opened this issue Sep 30, 2017 · 0 comments

Comments

@rhuffman
Copy link
Owner

The TimeLimiters use an ExecutorService to which their Callables are submitted. A Future is retained and, when the time limit is reached, the Future is cancelled.

Currently, the AttemptTimeLimiters.fixedTimeLimit method that does not take an ExecutorService creates a new cached thread pool every time it is used. (See the FixedAttemptTimeLimiter constructor.)

Because each call creates a new cached thread pool, none of the threads from any of the thread pools will ever be reused. Each pool will create a single thread, that thread will be used, the thread will remain alive but inactive for sixty seconds then die. At that point the cached thread pool can be garbage collected.

Instead of create a new thread pool each time it is invoked that FixedAttemptTimeLimiter constructor should use the same instance of a cached thread pool every time.

@rhuffman rhuffman added the bug label Sep 30, 2017
rhuffman added a commit that referenced this issue Sep 30, 2017
There is no need for the FixedAttemptTimeLimit that takes no executor
to create a new cached thread pool every time it is invoked. Instead,
all instances can use the same static cached thread pool so threads
are reused.

Fixes #17
@rhuffman rhuffman added the fixed label Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant