You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
-
You want the execution to overlap, right? So ScheduledThreadPoolExecutor won't work for you. If that is the case... why? Surely you can make the request asynchronously fast enough so that overlapping is not a problem. Then even Timer would work.Theraot– Theraot2019-11-21 12:06:53 +00:00Commented Nov 21, 2019 at 12:06
-
You only need threading in handling the responses, if at all. Making the requests can be centralised.Caleth– Caleth2019-11-21 13:10:38 +00:00Commented Nov 21, 2019 at 13:10
-
@Theraot : Some threads in my app will call 3-rd party API through a singleton REST client. I want that no matter which thread calls this client, an overlap of 100ms between calls. I do not think that timer will do the Job or I misunderstood something.Rouliboy– Rouliboy2019-11-21 13:31:02 +00:00Commented Nov 21, 2019 at 13:31
-
@Caleth : multiple threads call call the REST client.Rouliboy– Rouliboy2019-11-21 13:31:36 +00:00Commented Nov 21, 2019 at 13:31
-
@Rouliboy overlap means that it will awake a thread to make a request even if there are other threads that haven't ended. That is, if you have an interval of 100ms without overlap, they will queue up when it takes too long to make the request. On the other hand, an interval of 100ms with overlap can have multiple threads requesting at the same time when they take longer than 100ms to make the request. If you do not want overlap (i.e. you want them to queue up), then Timer will work. Now, are requests slow enough that overlap matters? Using Timer, there would be no queue, if requests are fast.Theraot– Theraot2019-11-21 13:46:18 +00:00Commented Nov 21, 2019 at 13:46
|
Show 4 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-java